//
// Created by jal on 18-9-2.
//
#include <bits/stdc++.h>
using namespace std;
int n;
const int MAXN = 10;
int book[MAXN];
int out[MAXN];
void dfs(int step){
if(step >= n){
copy(out, out+n, ostream_iterator<int>(cout, " "));//c++输出流
cout << endl;
return;
}
for(int i = 1; i <= n; i++){
if(book[i] == 0){
book[i] = 1;
out[step] = i;
dfs(step+1);
book[i] = 0;
}
}
}
int main() {
cin >> n;
dfs(0);
}
1--n的全排列----啊哈算法
最新推荐文章于 2022-06-24 18:16:37 发布