You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
493 B
27 lines
493 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
int n, r;
|
|
const int N = 110;
|
|
int a[N];
|
|
|
|
void dfs(int step, int m) {
|
|
if (step == n + 1) return;
|
|
if (m == r) {
|
|
for (int i = 1; i <= r; i++) printf("%3d", a[i]);
|
|
printf("\n");
|
|
return;
|
|
}
|
|
//下一个数字选择上
|
|
a[m + 1] = step + 1;
|
|
dfs(step + 1, m + 1);
|
|
|
|
//下一个数字放弃掉
|
|
dfs(step + 1, m);
|
|
}
|
|
|
|
int main() {
|
|
cin >> n >> r;
|
|
dfs(0, 0);
|
|
return 0;
|
|
} |