next_permutation(begin,end)
When there are arranged the one kind (in lexicographic order) discharge method returns true
, otherwisefalse
Return true
simultaneously from the array into the next one kind lexicographically discharge method.
Test code:
// Created by CAD on 2020/1/15.
#include <bits/stdc++.h>
#include <ext/rope>
using namespace std;
int main()
{
int a[4]={1,2,3};
do{
for(int i=0;i<=2;++i)
cout<<a[i]<<" ";cout<<endl;
}while(next_permutation(a,a+3));
return 0;
}
Output:
1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1