next_permutation函数的使用
来源:互联网 发布:飞利浦脱毛器 知乎 编辑:程序博客网 时间:2024/05/16 14:58
#include<iostream>#include<stdio.h>#include<algorithm>#include<string.h>using namespace std;int main(){ int a[]={1,2,3}; do{ printf("%d %d %d\n",a[0],a[1],a[2]); }while(next_permutation(a,a+3)); return 0;}next_permutation函数把所有的排列按照字典树输出来,全排列算法
对于字符串的输入同样适用,例如输入asd
#include<iostream>#include<string.h>#include<algorithm>#include<stdio.h>using namespace std;int main(){ string str; cin>>str; sort(str.begin(),str.end()); cout<<str<<endl; //把第一个输出即ads while(next_permutation(str.begin(),str.end())) { cout<<str<<endl; //输出剩下的5个 }}
0 0
- next_permutation函数的使用
- c++ next_permutation()函数的使用
- 排列函数 prev_permutation和next_permutation的使用
- hdu1716 STL next_permutation函数的使用
- next_permutation的函数
- next_permutation函数的应用
- next_permutation 函数的应用
- STL的next_permutation函数
- next_permutation 的使用
- next_permutation的使用
- 使用stl的next_permutation
- next_permutation的使用
- next_permutation 的使用
- 使用STL的next_permutation函数生成全排列(C++)
- 使用STL的next_permutation函数生成全排列(C++)
- 使用STL的next_permutation函数生成全排列(C++)
- 使用STL的next_permutation函数生成全排列(C++)
- 使用STL的next_permutation函数生成全排列(C++)
- 改善C#程序的建议9:使用Task代替ThreadPool和Thread
- 文章标题
- HDOJ 题目3478 Catch(染色法判二分图)
- 题目1182:统计单词
- 内存体系 用共享段于进程间联系
- next_permutation函数的使用
- 使用javah编译生成c的.h文件
- boost property_tree 解析json文件
- java学习笔记
- Info.plist与Prefix.pch修改文件位置遇到的问题及解决方法
- 【Javaweb】Eclipse for JavaEE新建的Web工程自动生成web.xml
- hdu 4436 str2int (后缀自动机+dp)
- C++ 二级指针和二维数组
- TCP/IP详细学习笔记(1)ARP与RARP