数字的全排列(next_permutation)
1 #include
2 #include /// next_permutation, sort
3 using namespace std;
4 int main () {
5 int myints[] = {1,2,3,1};
6 sort (myints,myints+4);
7
8 do {
9 cout << myints[0] << ’ ’ << myints[1] << ’ ’ << myints[2] << ’ ‘<< myints[3]<<’\n’;
10 } while ( next_permutation(myints,myints+4) ); ///获取下一个较大字典序排列
11
12 cout << "After loop: " << myints[0] << ’ ’ << myints[1] << ’ ’ << myints[2] << ’ ‘<< myints[3] <<’\n’;
13 return 0;
14 }