博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
对称排序
阅读量:5366 次
发布时间:2019-06-15

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

1 /*   2 对称排序  3 时间限制:1000 ms  |  内存限制:65535 KB  4 难度:1  5 描述  6 In your job at Albatross Circus Management (yes, it's run by a bunch of clowns), you have just finished writing a program whose output is a  7 list of names in nondescending order by length (so that each name is at least as long as the one preceding it). However, your boss does not   8 like the way the output looks, and instead wants the output to appear more symmetric, with the shorter strings at the top and bottom and the   9 longer strings in the middle. His rule is that each pair of names belongs on opposite ends of the list, and the first name in the pair is  10 always in the top part of the list. In the first example set below, Bo and Pat are the first pair, Jean and Kevin the second pair, etc.  11 输入 12 The input consists of one or more sets of strings, followed by a final line containing only the value 0. Each set starts with a line  13 containing an integer, n, which is the number of strings in the set, followed by n strings, one per line, NOT SORTED. None of the strings  14 contain spaces. There is at least one and no more than 15 strings per set. Each string is at most 25 characters long.  15 输出 16 For each input set print "SET n" on a line, where n starts at 1, followed by the output set as shown in the sample output. 17 If length of two strings is equal,arrange them as the original order.(HINT: StableSort recommanded) 18 样例输入 19 7 20 Bo 21 Pat 22 Jean 23 Kevin 24 Claude 25 William 26 Marybeth 27 6 28 Jim 29 Ben 30 Zoe 31 Joey 32 Frederick 33 Annabelle 34 5 35 John 36 Bill 37 Fran 38 Stan 39 Cece 40 0 41 样例输出 42 SET 1 43 Bo 44 Jean 45 Claude 46 Marybeth 47 William 48 Kevin 49 Pat 50 SET 2 51 Jim 52 Zoe 53 Frederick 54 Annabelle 55 Joey 56 Ben 57 SET 3 58 John 59 Fran 60 Cece 61 Stan 62 Bill 63 来源 64 POJ 65 上传者 66 sadsad 67 */ 68 #include
69 #include
70 int main() 71 { 72 char s[16][26],c[16][26],a[26]; 73 int n, i, j, k,t=1; 74 while(scanf("%d",&n) != EOF && n) 75 { 76 getchar(); 77 for(i=0; i
strlen(s[j+1]) ) 86 { 87 strcpy(a,s[j]); 88 strcpy(s[j],s[j+1]); 89 strcpy(s[j+1],a); 90 } 91 } 92 } 93 //按题目要求输出 94 j=k=0; 95 printf("SET %d\n",t++); 96 for(i=0; i

 

转载于:https://www.cnblogs.com/a604378578/p/3658912.html

你可能感兴趣的文章
MySQL各存储引擎
查看>>
项目--简单导出CSV文件
查看>>
Oracle session相关数据字典(一)
查看>>
C#用正则表达式 获取网页源代码标签的属性或值
查看>>
BZOJ 3399 [Usaco2009 Mar]Sand Castle城堡(贪心)
查看>>
WCF(一) 简单的认知
查看>>
[MFC][DShow]简单例子
查看>>
js onclick事件传参
查看>>
WiCloud 商业Wi-Fi管理平台
查看>>
团队项目--未完待续
查看>>
双重标准,我该怎么解决
查看>>
python中的网页标签等字符处理
查看>>
Linux常用命令(十二)
查看>>
Linux常用命令(十五)
查看>>
Linux常用命令(十四)
查看>>
Linux常用命令(十七)
查看>>
Linux常用命令(十六)
查看>>
day 3 修改haproxy.cfg 作业
查看>>
sim usim Uim 区别
查看>>
网页中插入透明Flash的方法和技巧
查看>>