标签:
next_permutation函数既可用于非重排列也可用于重排列;
#include <bits/stdc++.h>
#define MAXN 200000+10
#define ll long long
using namespace std;
int a[MAXN];
int main(void)
{
int n;
cin >> n;
for(int i=0; i<n; i++)
cin >> a[i];
sort(a, a+n);
do
{
for(int i=0; i<n; i++)
cout << a[i] << " ";
cout << endl;
}while(next_permutation(a, a+n));
return 0;
}
标签:
原文地址:http://www.cnblogs.com/geloutingyu/p/5831523.html