next_premutation
来源:互联网 发布:淘宝3000多的实体娃娃 编辑:程序博客网 时间:2024/05/17 17:38
全排列函数,重新排列范围内的元素[第一,最后一个)使其转换为按照字典序排列的下一个值较大的组合,若存在下个较大的组合返回true,否则返回false。
#include<cstdio>#include<algorithm>using namespace std;int main(){int a[10];a[0]=1,a[1]=2,a[2]=3;while( next_permutation(a,a+3) ){for(int i=0;i<3;i++){printf("%d ",a[i]);}printf("\n");}return 0;}
结果
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1
同理,prev_premutation()提供降序排列
0 0
- next_premutation
- next_premutation
- STL next_premutation函数的C++和C的作用。
- 快速学习stl(next_premutation)全排列;nyoj会排序的小明
- H5中的标签(一)
- 删除数组零元素
- poj3420(状态压缩+矩阵加速)
- wikioi1001 舒适的路线
- Mybatis(第一天 基础知识)
- next_premutation
- 机器人的运动范围(DFS)
- Qt在mysql语句中如何使用变量
- 聊天室
- HDU-1142-最短路+记忆化搜索
- LightOJ 1106 Gone Fishing 贪心, DP, 堆优化 2017年1月23日
- 笔记6
- 1031.Hello World for U (20)
- BUPT OJ 非平方等式