使用STL的next_permutation函数生成全排列 ,注意next_permutation求的是按字典序的全排列,所以要先排序。
函数声明:
#include <algorithm> bool next_permutation( iterator start, iterator end );
解释:
The next_permutation() function attempts to transform the given range of elements [start,end) into the next lexicographically greater permutation of elements. If it succeeds, it returns true, otherwise, it returns false.