hhhhh学到了,next_permutation的用法,stl牛逼!!!
#include<bits/stdc++.h>
using namespace std;
const int N=100010;
int q[N];
int main(){
int n;
cin>>n;
int w[N];
for(int i=1;i<=n;i++)q[i]=i;
do{
for(int i=1;i<=n;i++)cout<<q[i]<<' ';
cout<<endl;
}while(next_permutation(q+1,q+1+n));
return 0;
}
stl你比