全排列函数(next_permutation)
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; int main() { int a[10]; int n; scanf("%d",&n); for(int i = 1; i <= n ; i++) scanf("%d",&a[i]); sort(a+1,a+n+1); do{ for(int i = 1; i < n ;i++) printf("%d ", a[i]); printf("%d\n", a[n]); } while(next_permutation(a+1,a+n+1)); return 0; }