next_permutation与prev_permutation
来源:互联网 发布:java 动态脚本语言 编辑:程序博客网 时间:2024/05/16 19:34
STL真是好东西。
#include<algorithm>
next_permutation()函数功能是输出所有比当前排列大的排列,顺序是从小到大。
当排列已经是最大,返回假,否则真。
prev_permutation()函数功能是输出所有比当前排列小的排列,顺序是从大到小。
当排列已经是最小,返回假,否则真。
#include<iostream>#include<cstdio>#include<algorithm>#include<string>using namespace std;int main(){ int a[3]; a[0]=1;a[1]=2;a[2]=3; do{ cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl; } while(prev_permutation(a,a+3)); ///已经是最小,只循环一次 cout<<endl; int k=0; int b[4]={1,2,3,4}; do{ cout<<++k<<endl; cout<<b[0]<<b[1]<<b[2]<<b[3]<<endl; }while(next_permutation(b,b+4)); /// 循环24次, A(4,4);直到数组为4,3,2,1;返回假,循环结束 return 0;}
0 0
- next_permutation与prev_permutation
- next_permutation & prev_permutation
- next_permutation,prev_permutation
- next_permutation & prev_permutation
- STL的next_permutation与prev_permutation解析
- 全排列函数next_permutation与prev_permutation
- STL prev_permutation&next_permutation
- STL next_permutation and prev_permutation
- next_permutation 与 prev_permutation的用法 (全排列)
- C++ 全排列函数 std::next_permutation与std::prev_permutation
- stl全排列next_permutation()与prev_permutation()函数用法
- 全排列函数next_permutation,prev_permutation
- stl中的next_permutation和prev_permutation
- STL/next_permutation()和prev_permutation()函数
- 黑科技(next_permutation和prev_permutation)
- next_permutation函数和prev_permutation函数
- 泛型算法系列27:next_permutation()&&prev_permutation()
- next_permutation/prev_permutation详解
- ctype.h 参考
- char与byte的区别
- 速来膜拜!20位活跃在Github上的国内技术大牛
- Andriod PackageManager使用
- hdu 4937 Lucky Number(数学题 进制转换)2014多校训练第7场
- next_permutation与prev_permutation
- asp中URL传参遇空格字符串被截断
- FFmepg 多线程解码历程
- 【Python】【List】去除列表中重复的元素
- 8个前沿的 HTML5 & CSS3 效果(附源码)
- MySQL内核月报 2014.08
- 公交车身媒体新优势
- android获得控件在屏幕中的绝对坐标 getLocationInWindow 和 getLocationOnScreen
- java中的IO操作