51nod 1384 全排列(next_permutation()函数)
来源:互联网 发布:sql改变表结构的语句 编辑:程序博客网 时间:2024/05/16 17:43
1384 全排列
基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题
收藏
关注
给出一个字符串S(可能又重复的字符),按照字典序从小到大,输出S包括的字符组成的所有排列。例如:S = "1312",
输出为:
1123
1132
1213
1231
1312
1321
2113
2131
2311
3112
3121
3211
Input
输入一个字符串S(S的长度 <= 9,且只包括0 - 9的阿拉伯数字)
Output
输出S所包含的字符组成的所有排列
Input示例
1312
Output示例
112311321213123113121321211321312311311231213211
来来来,这里有个菊苣的链接,给大家进去膜一膜,一下就懂了~:http://blog.sina.com.cn/s/blog_9f7ea4390101101u.html
好了,废话不多说,上代码吧= ̄ω ̄=
#include<stdio.h>#include<string.h>#include<string.h>#include<algorithm>#include<iostream>#include<map>using namespace std;string a[100000];char b[50];int cmp(char a,char b){return a<b;}int main(){int i,j,sum=1,len;scanf("%s",b);len=strlen(b);sort(b,b+len,cmp);char *st=b;char *en=b+len;do{printf("%s\n",b);}while(next_permutation(st,en));return 0;}
0 0
- 51nod 1384 全排列(next_permutation函数)
- 51nod 1384 全排列(next_permutation()函数)
- 51nod 1384 全排列(next_permutation)
- 【51nod】1384 全排列 next_permutation
- 51nod 1384 全排列 (dfs/next_permutation)
- 1384 全排列 next_permutation()函数
- 全排列函数 next_permutation()
- next_permutation函数(全排列)
- next_permutation函数(全排列)
- 全排列 next_permutation()函数
- hdu1027 全排列(STL函数next_permutation)
- 51nod:1384 全排列(dfs||c++函数)
- 全排列(next_permutation)
- next_permutation(全排列)
- 全排列函数next_permutation,prev_permutation
- 【全排列】next_permutation函数 【algorithm】
- 【51Nod】1384 - 全排列(STL)
- 51Nod-1384 全排列(回溯)
- Leetcode 202. Happy Number
- 服务器端签购单数据量和压测数据量不一致
- day19字节流和字符流转换,明确源和目的
- Android自定义ProgressBar的样式
- 半年总结(2016年上半年)
- 51nod 1384 全排列(next_permutation()函数)
- 一致性代码段和非一致性代码段
- 关于分治
- PHP面向对象留言板(三)模拟客户端传来的JSON格式的数据写入数据库
- java 异常
- 使用Gradle和Sonatype Nexus 搭建私有maven仓库
- c++构造函数详解
- AndroidStudio使用GreenDao的方法
- Keras中神经网络可视化模块keras.utils.visualize_util 的安装配置与错误解决办法