View Code
//头文件:#include <algorithm> //O(N!) const int maxn = 1000; int num[maxn]; void permut(int n) { //n:元素个数 int i,j,k; sort(num,num+n); //注意排序 do { for(i=0;i<n;i++) printf("%d ",num[i]); printf("\n"); }while(next_permutation(num,num+n)); }