文章目录
1.求全排列
#include<iostream>
using namespace std;
const int lp=110;
int n;
int path[lp];
bool st[lp];
void dfs(int u){
if(u==n){
for(int i=0;i<n;i++) cout<<path[i]<<' ';
cout<<endl;
}
for(int i=1;i<=n;i++){
if(!st[i]){
st[i]=true;
path[u]=i;
dfs(u+1);
st[i]=false;
}
}
}
int main(){
cin>>n;
dfs(0);
return 0;
}