博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Anagram
阅读量:5925 次
发布时间:2019-06-19

本文共 2116 字,大约阅读时间需要 7 分钟。

Description

You are to write a program that has to generate all possible words from a given set of letters. Example: Given the word "abc", your program should - by exploring all different combination of the three letters - output the words "abc", "acb", "bac", "bca", "cab" and "cba". In the word taken from the input file, some letters may appear more than once. For a given word, your program should not produce the same word more than once, and the words should be output in alphabetically ascending order.

Input

The input consists of several words. The first line contains a number giving the number of words to follow. Each following line contains one word. A word consists of uppercase or lowercase letters from A to Z. Uppercase and lowercase letters are to be considered different. The length of each word is less than 13.

Output

For each word in the input, the output should contain all different words that can be generated with the letters of the given word. The words generated from the same input word should be output in alphabetically ascending order. An upper case letter goes before the corresponding lower case letter.

Sample Input

3aAbabcacba

Sample Output

AabAbaaAbabAbAabaAabcacbbacbcacabcbaaabcaacbabacabcaacabacbabaacbacabcaacaabcabacbaa ********************************************************************************************************** STL中next_permutation()的函数的应用 **********************************************************************************************************
1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 using namespace std; 9 char str1[1001];10 int num;11 int val(char c)12 {13 if(isupper(c))14 return (c-'A')*2;15 if(islower(c))16 return (c-'a')*2+1;17 }18 bool cmp(char a,char b)19 {20 return val(a)
>num;25 while(num--)26 {27 scanf("%s",str1);28 int len=strlen(str1);29 sort(str1,str1+len,cmp);30 do31 {32 cout<
<
View Code

坚持!!!!!!!!

转载于:https://www.cnblogs.com/sdau--codeants/p/3297281.html

你可能感兴趣的文章
HTTPS实现原理
查看>>
sort命令详解及Nginx统计运用
查看>>
SElinux
查看>>
Hyper-V: Windows hypervisor must be running
查看>>
db2诊断系列之---定位锁等待问题
查看>>
no ip domain-lookup 什么意思
查看>>
keepalived 原理,安装,配置
查看>>
/hgfs下无共享文件夹?/mnt下没有hgfs文件夹?vmhgfs-fuse:找不到命令?
查看>>
51. Python 数据处理(2)
查看>>
linux 怎么完全卸载mysql数据库
查看>>
我的友情链接
查看>>
MTD/MT/MDD/MD以及LIB/DLL之间的一些联系和问题
查看>>
Linux存储管理
查看>>
我的友情链接
查看>>
swf 文件在线播放的,怎么能够下载呢?(除视频外其它都可)
查看>>
通用路由封装(GRE)×××配置
查看>>
SCVMM 2012 R2运维管理九之:添加非信任的Hyper-v主机和群集
查看>>
struts.properties属性解释
查看>>
Java基础---变量(三)
查看>>
Monkey测试实例
查看>>