UVA10098 Generating Fast【全排列】
来源:互联网 发布:梦幻修仙2数据库修改 编辑:程序博客网 时间:2024/06/06 03:02
Generating permutation has always been an important problem in computer science. In this problemyou will have to generate the permutation of a given string in ascending order. Remember that youralgorithm must be efficient.
Input
The first line of the input contains an integer n, which indicates how many strings to follow. The nextn lines contain n strings. Strings will only contain alpha numerals and never contain any space. Themaximum length of the string is 10.
Output
For each input string print all the permutations possible in ascending order. Not that the strings shouldbe treated, as case sensitive strings and no permutation should be repeated. A blank line should followeach output set.
Sample Input
3
ab
abc
bca
Sample Output
ab
ba
abc
acb
bac
bca
cab
cba
abc
acb
bac
bca
cab
cba
问题链接:UVA10098 Generating Fast。
题意简述:参见上文。
问题分析:这个问题是按字典序从小到大输出字符串的全排列。程序说明:(略)
题记:(略)
AC的C++语言程序如下:
/* UVA10098 Generating Fast */#include <iostream>#include <algorithm>#include <stdio.h>#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;}
- UVA10098 Generating Fast【全排列】
- uva10098 - Generating Fast(快速生成有序排列)
- Generating Fast UVA10098
- uva10098 Generating Fast
- UVa10098 Generating Fast, Sorted Permutation
- uva10098 Generating Fast, Sorted Permutation
- UVa 10098 Generating Fast (全排列生成)
- uva 10098 - Generating Fast(全排列)
- UVA - 10098 Generating Fast (全排列)
- uva 10098 Generating Fast(全排列)
- UVA - 10098 - Generating Fast(全排列)
- uva-10098-Generating Fast-全排列典例
- UVA 10098 - Generating Fast 解题报告 (全排列)
- UVA 10098 Generating Fast, Sorted Permutation(全排列)
- uva10098(简单题)-全排列
- uva10098 全排列分分钟搞定
- uva10098排列
- uva10098--排列
- BZOJ 2427 [HAOI2010]软件安装 Tarjan+树上动态规划
- 【Docker容器的数据管理】-【Docker数据卷容器】- 挂在数据卷容器的方法
- Excel图表-用三维堆积柱形图展示各地GDP的对比效果
- Excel应用-各地GDP的综合对比图表-Part1(三维柱形图、数据点雷达图、复合图)
- Window server 2008 搭建DNS服务器
- UVA10098 Generating Fast【全排列】
- VM三种连接模式
- 【Docker容器的数据管理】-【Docker数据卷的备份和还原】- 数据卷备份
- UVA146 POJ1146 ID Codes【全排列】
- 不忘初心 二次创业
- 平凡浙商人 感动点滴间
- 小灶
- Tomcat项目部署的三种方法
- Codeforces Round #422 (Div. 2) D. My pretty girl Noora(数论)