ZOJ 2172题解 一道水题没啥好说的代码贴在这了。

 1 #include<stdio.h>
2 #include<string.h>
3
4 int main()
5 {
6 int ncases, i, j, k=1, n;
7 char a[16][30], b[16][30];
8
9 while(scanf("%d", &ncases) != EOF)
10 {
11 if (ncases == 0) break;
12 for (i=1; i<=ncases; i++)
13 {
14 scanf("%s", a[i]);
15 }
16 printf("SET %d\n", k);
17 k++;
18 if (ncases%2 == 0)
19 n = ncases/2;
20 else
21 n = ncases/2+1;
22 for (i=1,j=1; i<=ncases,j<=n; i+=2,j++)
23 {
24 strcpy(b[j],a[i]);
25 }
26 for (i=2,j=ncases; i<=ncases,j>n; i+=2,j--)
27 {
28 strcpy(b[j],a[i]);
29 }
30 for (i=1; i<=ncases; i++)
31 {
32 printf("%s\n", b[i]);
33 }
34 }
35 return 0;
36 }
37
posted @ 2011-09-24 22:30  zhongya  阅读(151)  评论(0编辑  收藏  举报