关于next_permutation的用法
来源:互联网 发布:淘宝买处方药 编辑:程序博客网 时间:2024/06/15 00:51
next_permutation是STL中的一个函数,头文件是#include<algorithm>,作用是生成全排列,默认是后一个比前一个大
例如aacc,生成全排列后为:acac acca caac caca ccaa ,根据ASCALL码的顺序排列,加上本身共6个!
函数模型:
bool next_permutation(first, last);
bool next_permutation(first,last,cmp); cmp为比较函数,自己定义即可。
CODE:
#include<stdio.h>#include<algorithm>
#include<string.h>
using namespace std;
int main()
{
int len,count=0;
char s[20];
gets(s); //貌似不能用scanf("%c",s[i]),可用scanf("%s",s)直接输入
len=strlen(s);
sort(s,s+len);
while(next_permutation(s,s+len))
{
puts(s);//同理
count++;
}
printf("%d\n",count+1);
return 0;
}
更多更详细的介绍请进 http://www.cplusplus.com/reference/algorithm/next_permutation/
http://www.slyar.com/blog/stl_next_permutation.html
PS:现阶段只知道这么多,本人只是抛砖引玉,希望各位大神指点指点!!
- 关于next_permutation的用法
- 关于全排列 next_permutation() 函数的用法
- 关于全排列 next_permutation() 函数的用法
- next_permutation的思想和用法
- 全排列next_permutation()的用法
- next_permutation()的用法,与作用
- 关于next_permutation函数的模拟!
- next_permutation用法
- next_permutation(,)用法
- 关于next_permutation
- C++STL的next_permutation 的用法
- 有关next_permutation()函数的用法, poj 2718
- Permutations II stl next_permutation的用法
- next_permutation(排列组合)函数的用法
- HDU1716 排列2 next_permutation的用法
- next_permutation和prev_permutation函数的用法
- next_permutation的简单用法及例题
- 全排列函数next_permutation的用法
- handler机制
- 从“DMAIC”到“DMADV”——六西格玛实现质量经济性管理的最新实践
- CentOS添加163源和EPEL
- URAL 1009/URAL 1012/URAL 1013
- 11gR2 集群(CRS/GRID)新功能——SCAN(Single Client Access Name)
- 关于next_permutation的用法
- Buffer Busy Waits 你误解了吗?
- 虚拟网卡TUN/TAP设备使用实例
- Hibernate继原理分析之后2
- boost shared_ptr 基类转到子类 boost::dynamic_pointer_cast
- QWidget与HWND的互相转换
- hibernate3种状态引起的问题
- android电池(五):电池 充电IC(PM2301)驱动分析篇
- 详解MySQL中EXPLAIN解释命令