【STL】 next_permutation用法
来源:互联网 发布:淘宝助理怎么上架商品 编辑:程序博客网 时间:2024/05/29 14:47
关于nextpermutation,应该是相对方便的一个STL工具,它的返回值是一个bool类型,这个函数本身的作用就是返回当前序列的下一个字典序,当这个序列没有下一个字典序后,也就是当前序列的字典序最大的时候,返回false。结合while循环,可以求出整个的字典序。
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;#define maxn 20int main (){char arr[maxn];while(scanf("%s",&arr) != EOF){int len = strlen(arr);sort(arr,arr+len);do{printf("%s\n",arr);}while(next_permutation(arr,arr+len));}return 0;}
当然,也可以不用sort,那么返回的就是输入字符串的后面的字典序列。
0 0
- 【STL】 next_permutation用法
- 【STL】next_permutation函数用法
- STL中的next_permutation函数用法
- C++STL的next_permutation 的用法
- Permutations II stl next_permutation的用法
- STL库——next_permutation用法
- STL next_permutation
- 【STL】next_permutation
- [STL]next_permutation
- 全排列问题的STL用法(next_permutation类)
- C++ STL algorithm库中 next_permutation()用法 注意事项
- 全排列问题的STL用法(next_permutation类)
- stl全排列next_permutation()与prev_permutation()函数用法
- C++ STL next_permutation() prev_permutation(a,a+n)用法。
- next_permutation用法
- next_permutation(,)用法
- stl算法:next_permutation剖析
- POJ1061(STL next_permutation)
- Unity手游开发--NGUI实现冷却技能(CD)功能
- ubuntu下SVN服务器安装配置
- 机房合作(二):我怎样做组长(编码本身不重要)
- 黑马程序员——OC三大特性----封装、继承、多态
- Leetcode2: Rotate Array
- 【STL】 next_permutation用法
- Array.forEach() & Using square brackets to obtain the value of a property
- 排序算法--计数排序(java)
- OJ 002 Add Two Numbers
- Mac应用程序提升为管理员权限的方法
- STL/next_permutation()和prev_permutation()函数
- 本地tomcat加载js没问题,但是放到远程上就报404
- PHP开发中的乱码问题
- 队列 广搜 nyoj 58 最少步数