uva10098 全排列分分钟搞定
来源:互联网 发布:mac下面图标怎么放大 编辑:程序博客网 时间:2024/05/18 00:54
Time limit: 3.000 seconds
http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=1039
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
ba
abc
acb
bac
bca
cab
cba
abc
acb
bac
bca
cab
cba
#include<iostream>#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int main(){ int t; scanf("%d",&t); while(t--) { char a[13]; scanf("%s",a); int len=strlen(a); sort(a,a+len); do { for(int i=0;i<len;i++) printf("%c",a[i]); printf("\n"); }while(next_permutation(a,a+len)); printf("\n"); } return 0;}
- uva10098 全排列分分钟搞定
- UVA10098 Generating Fast【全排列】
- uva10098(简单题)-全排列
- uva10098排列
- uva10098--排列
- 分分钟搞定汉诺塔
- 分分钟搞定iOS远程消息推送
- 分分钟搞定IOS远程消息推送
- 分分钟搞定IOS远程消息推送
- 分分钟钟搞定iOS自定义相机
- 分分钟搞定python破解无线wifi
- uva10098
- uva10098
- uva10098
- UVA10098
- uva10098 - Generating Fast(快速生成有序排列)
- 5-2 输出全排列 (20分)
- 输出全排列(20 分)
- 数字签名是什么? 对称加密 与非对称加密
- CentOS安装 /BOOT分盘挂载无法修改大小解决方法
- LeetCode 043 Multiply Strings
- Ubuntu下查看Printk的输出
- Android Drawable - Clip Drawable使用详解(附图)
- uva10098 全排列分分钟搞定
- JDBC连接Oracle的示例代码
- 【Android进阶】Android常见的几种RuntimeException
- IE无法上网,但其他浏览器可以
- Mac OS X 下 Android6.0源码的下载与编译
- Sicily1544——Integer Generator
- Android M MO流程 并与Android L MO对比
- Leetcode Regular Expression Matching O(n^2) DP
- HDUOJ_2564_词组缩写