C++全排列函数:
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int a[3]={2,8,5};
do
{
cout<<a[0]<<a[1]<<a[2]<<endl;
}
while(next_permutation(a,a+3));
cout<<endl<<endl;
sort(a,a+3);
do
{
cout<<a[0]<<a[1]<<a[2]<<endl;
}
while(next_permutation(a,a+3));
return 0;
}
输出结果:
285
528
582
825
852
258
285
528
582
825
852