不知道为什么编译失败。
我测试了gcc和msvc都能编译成功,这就奇怪了
#include <iostream>
using namespace std;
const int N = 12;
int n, k;
int solution[N];
bool st[N];
dfs(int x){
if(x == k){
for(int i = 0; i < k; ++i) {
cout << solution[i] << " ";
}
puts("");
}
for(int i = 1; i <= n; ++i){
if(!st[i]){
solution[x] = i;
st[i] = true;
dfs(x + 1);
st[i] = false;
}
}
}
int main(){
cin >> n >> k;
dfs(0);
return 0;
}