c++中next_permutation的使用
#include<iostream>
#include<algorithm>
using namespace std;
main()
{
int i,j=0;
int a[5]={1,2,3,4,5};
do
{
for(i=0;i<5;i++){
cout <<a[i]<<" ";
}
cout <<endl;
}while(next_permutation(a,a+5));
}
结果输出a[5]数组的全排列
使用规则:
1.需要引用algorithm
2.next_permutation(需要排列的数组开始的地方,需要排列的数组结束的地方)

浙公网安备 33010602011771号