UVa10098 Generating Fast, Sorted Permutation
来源:互联网 发布:凯撒大帝3mac 秘籍大全 编辑:程序博客网 时间:2024/06/05 08:37
Problem C
Generating Fast, Sorted Permutation
Input: Standard Input
Output: Standard Output
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
3ab
abc
bca
Sample Output
abba
abc
acb
bac
bca
cab
cba
abc
acb
bac
bca
cab
cba
Shahriar Manzoor
这题也确实没有什么好说的,简单的全排列题目,next_permutation()真的挺好用的。
#include<iostream>#include<cstring>#include<algorithm>using namespace std;const int N = 20;char s[N];int main(){int n;cin >> n;while (n--){memset(s,0,sizeof(s));cin >> s;int len = strlen(s);sort(s,s+len);cout << s << endl;while (next_permutation(s,s+len)){cout << s << endl;}cout << endl;}return 0;}
- UVa10098 Generating Fast, Sorted Permutation
- uva10098 Generating Fast, Sorted Permutation
- Generating Fast, Sorted Permutation
- Generating Fast, Sorted Permutation
- Generating Fast UVA10098
- uva10098 Generating Fast
- uva 10098 Generating Fast, Sorted Permutation
- uva--10098--Generating Fast, Sorted Permutation
- UvaOJ 10098 Generating Fast, Sorted Permutation
- UVA10098 Generating Fast【全排列】
- uva10098 - Generating Fast(快速生成有序排列)
- UVA 10098 Generating Fast, Sorted Permutation(全排列)
- UVa 10098 Generating Fast
- 10098--Generating Fast
- uva 10098 - Generating Fast
- 10098 - Generating Fast
- UVa 10098 Generating Fast
- UVaOJ 10098 - Generating Fast
- Qt 自制文件浏览器并实现按照扩展名过滤
- java设计模式---观察者模式
- c中各种++的比较
- 例题7.1.1,除法
- 关于全国大学生电子设计竞赛
- UVa10098 Generating Fast, Sorted Permutation
- [MFC]选择目录对话框和选择文件对话框
- 《Android内核剖析》笔记 第2章 Java基础&异步消息处理模型
- Linux xargs命令
- Deploying Studio Applications
- Extjs实战(Extjs+Spring+Hibernate+dwr)章二:控件的组件化(二) 代码演示
- asp.net中session的原理及应用
- 指针基础
- django 非常实用的无限级分类功能