标准组合型枚举
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 30;
int n,m;
int ways[N];
void dfs(int u,int start){
if(u == m + 1){
for(int i = 1; i<=m; i++) printf("%d ",ways[i]);
puts("");
return;
}
for(int i = start; i<=n; i++){
ways[u] = i;
dfs(u+1,i+1);
ways[u] = 0;
}
}
int main(){
cin >> n >> m;
dfs(1,1);
return 0;