C语言中没有吧?C++中倒是有一个:
next_permutation(array,array+arrlength)
使用的头文件是#include <algorithm>
示例:
#include <iostream>
#include <algorithm> /// next_permutation, sort
using namespace std;
int main () {
int myints[] = {1,2,3,1};
sort (myints,myints+4);
do {
cout << myints[0] << ' ' << myints[1] << ' ' << myints[2] << ' '<< myints[3]<<'\n';
} while ( next_permutation(myints,myints+4) ); ///获取下一个较大字典序排列
cout << "After loop: " << myints[0] << ' ' << myints[1] << ' ' << myints[2] << ' '<< myints[3] <<'\n';
return 0;
}