next_permutation(prev_permutation)
有全排列函数两个:
- next_permutation(start,end)
 - prev_permutation(start,end)
 
前者求的是当前排列的下一个排列,后者求的是当前排列的上一个排列。(前后顺序为字典序)
有next_permutation的函数原型:
1  | #include<algorithm>  | 
有如下例子:
1  | #include <iostream>  | 
输出结果为:
1  | 1 2 3  | 
总结:next_permutation(num,num+n)对数组中前 n 个元素进行全排列。
此外,有next_permutation(node,node+n,cmp),可以对结构特(或其他规则)按照自定义的排序方式进行排序。