51nod1384 全排列
来源:互联网 发布:js秒杀脚本 编辑:程序博客网 时间:2024/06/11 23:01
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
题意:中文题!
思路:把string转成char数组,采用next_permutation(iterator start,iterator end);函数求解,头文件#include<algorithm>
#include <iostream>#include<string>#include<algorithm>#include<string.h>using namespace std;const int maxn=10;char ch[maxn];int main(){ string str; cin>>str; int len=str.length(); for(int i=0;i<len;i++) { ch[i]=str[i]; } sort(ch,ch+len); do { for(int i=0;i<len;i++) cout<<ch[i]; cout<<endl; }while(next_permutation(ch,ch+len)); return 0;}
阅读全文
0 0
- 51nod1384 全排列
- 51nod1384全排列--STL
- 全排列问题 以51nod1384为例(字典序且重复)
- 全排列【51nod】【全排列】
- 51nod 全排列
- 51nod_1384 全排列
- 51nod_1384全排列
- 1384全排列【51NOD】
- 51NOD 1384 全排列
- 51nod 1384 全排列
- 51Nod--1384全排列
- 51NOD 1384 全排列
- 51nod 1750:全排列
- 51nod 1384 全排列
- 51nod 1384全排列
- 51nod 1384 全排列
- 51nod 1384 全排列
- 51Nod 1384 全排列
- jQuery源码学习笔记(02)
- 自律以自救
- 九、 通用工具 ----smart Pointer(智能指针)---weak_ptr
- 551. Student Attendance Record I
- 工作日记2017.08.25 MongoDB 聚合查询 aggregate
- 51nod1384 全排列
- 【Echarts】Uncaught TypeError: Cannot read property 'getAttribute' of null报错
- QTableWidget表头中增加checkbox以及QTableWidget各种小知识
- 记录:js删除数组中某一项或几项的几种方法
- hive select * 没有查询到数据
- Supervisor和Nginx常用命令
- PHP 正则匹配 反斜杠
- Unity2017 UGUI开发 之 字体渐变
- C++中的Lambda表达式详解