next_permutation 可以把n个元素的n!种不同的排列生成出来
next_permutation(start, end) : 当前排列的下一个排列
prev_permutation(start, end):当前排列的上一个排列
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int a[] = {1, 2, 3, 1};
sort(a, a+4);
do{
cout << a[0] << a[1] << a[2] << a[3] << endl;
}while(next_permutation(a, a+4));
return 0;
}