浙工大姗姗杯round1 E
来源:互联网 发布:乐乎青年社区客服电话 编辑:程序博客网 时间:2024/04/28 09:39
UVA - 10098 - Generating Fast
Generating permutation has always been an important problem in computer science. In this problem you will have to generate the permutation of a given string in ascending order. Remember that your algorithm must be efficient.
Input
The first line of the input contains an integer n, which indicates how many strings to follow. The next n lines contain n strings. Strings will only contain alpha numerals and never contain any space. The maximum length of the string is 10.
Output
For each input string print all the permutations possible in ascending order. Not that the strings should be treated, as case sensitive strings and no permutation should be repeated. A blank line should follow each output set.
Sample Input
3
ab
abc
bca
Sample Output
ab
baabc
acb
bac
bca
cab
cbaabc
acb
bac
bca
cab
cba
题意:给一个字符串,给出他的全排列
思路:神奇的next_permutation()函数
#include <iostream> #include <stdio.h>#include<algorithm>#include <string.h> using namespace std; const int N = 10;char s[N+1]; int main(){ int t, len; scanf("%d", &t); while(t--) { scanf("%s", s); len = strlen(s); sort(s, s + len); do { printf( "%s\n", s); } while(next_permutation(s, s + len)); printf( "\n"); } return 0;}
- 浙工大姗姗杯round1 E
- 浙工大姗姗杯round1 A
- 浙工大姗姗杯round1 C
- 浙工大姗姗杯round1 D
- 浙工大姗姗杯round1 F
- 浙工大姗姗杯round1 G
- 浙工大姗姗杯round2 G
- 浙工大姗姗杯round3 A
- 浙工大姗姗杯round2 CodeForces 103BCthulhu
- 浙工大姗姗杯round2 CodeForces 116BLittle Pigs and Wolves
- CF MemSQL Round1 E. The Red Button
- 2016"百度之星" - 资格赛(Astar Round1)Problem E(复杂模拟题)
- SRM 454 Round1 500
- SDOI2014 Round1 day0
- SDOI2014 Round1 day1
- SDOI2014 Round1 day2
- codeforces round1 p1
- SDOI2015 Round1总结
- C# 通过内存流将字节转换为相应数值
- spring-redis缓存方案学习一:原始template开发
- MySQL数据库一(数据库安装以及数据库的创建)
- JDK安装、环境变量配置
- ZOJ
- 浙工大姗姗杯round1 E
- 为什么选择图形数据库,为什么选择Neo4j?
- 序列化和反序列化
- 在eclipse中新建dubbo项目的时候引入dubbo的配置xml文件报错问题
- 【已解决】VS2017发布.net core 项目遇到 未能验证服务器的证书问题 发布时
- 这个周末你准备怎么过?
- MySql随机字符串
- 运算符重载 定义为类成员函数or非成员函数
- MPU6050简介(1)-基于正点原子的视频整理