正常递归解法,但是为什么加了注释的那一行就过不了了呢? b 好像也没有改变呀。
#include <iostream>
#define int long long
using namespace std;
int a, d;
int b[20], c[20];
void calc(int x, int y){
if (x == a){
for (int i = 0; i < x; i ++){
cout << c[i] << ' ';
}
puts("");
}
for (int i = y + 1; i <= d; i ++){
c[x] = i;
calc(x + 1, i);
}
}
signed main(){
cin >> d >> a;
calc(0, 0);
return 0;
}