next permutation函数(2)
来源:互联网 发布:java开发框架课程设计 编辑:程序博客网 时间:2024/06/11 13:15
原文链接http://blog.csdn.net/acdreamers/article/details/8544505点击打开链接
next_permutation的函数声明:#include <algorithm>
bool next_permutation( iterator start, iterator end);
next_permutation函数的返回值是布尔类型,在STL中还有perv_permutation()函数
next_permutation()函数功能是输出所有比当前排列大的排列,顺序是从小到大。
而prev_permutation()函数功能是输出所有比当前排列小的排列,顺序是从大到小。
next_permutation函数的原理如下:
在当前序列中,从尾端向前寻找两个相邻元素,前一个记为*i,后一个记为*t,并且满足*i < *t。然后再从尾端
寻找另一个元素*j,如果满足*i < *j,即将第i个元素与第j个元素对调,并将第t个元素之后(包括t)的所有元
素颠倒排序,即求出下一个序列了。
代码:
阅读全文
0 0
- next permutation函数(2)
- next permutation函数(3)
- next permutation函数
- next permutation函数
- next permutation函数
- LeetCode(31) Next Permutation
- LeetCode (31)Next Permutation
- Next Permutation
- Next Permutation
- Next Permutation
- Next Permutation
- Next Permutation
- Next Permutation
- Next Permutation
- Next Permutation
- Next Permutation
- Next Permutation
- Next Permutation
- Linux和Windows下安装最新版Git+教程
- cocos creator 中使用自定义shader
- LLVM\Clang 在Windows下可运行的配置
- 3D渲染管线基本的流程及其流程图
- next_permutation函数 (1)
- next permutation函数(2)
- next permutation函数(3)
- 《C语言及程序设计初步》_1.4C语言程序初体验_实践1——输出点阵图
- C语言的宏之带参数宏
- 安装wampserver后的配置工作
- Git获取Master分支中的某个文件夹下的所有文件
- c++ vector(1)
- 手机定位
- 线程