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 #include69 #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