0
点赞
收藏
分享

微信扫一扫

C++中全排列算法函数next_permutation的使用方法

首先,先看对next_permutation函数的解释: http://www.cplusplus.com/reference/algorithm/next_permutation/?kw=next_permutationC++中全排列算法函数next_permutation的使用方法_枚举

C++中全排列算法函数next_permutation的使用方法_枚举_02

 

从中可以看出,全排列的第一个序列为从小到大排好序的序列,最后一个序列为从大到小排好序的序列。

使用next_permutation函数的注意点:

在使用此函数之前,必须先对原序列使用sort进行排序,不然则不能获得其全部的全排列。


举报

相关推荐

0 条评论