hdu 1200 To and Fro

http://acm.hdu.edu.cn/showproblem.php?pid=1200

水题。

View Code
 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include<string.h>
 4 
 5 int main()
 6 {
 7     int n,i,len;
 8     char str[210];
 9     while(~scanf("%d",&n),n)
10     {
11           //getchar();
12           scanf("%s",str);
13           len=strlen(str);
14           for(i=0;i<n;i++)
15           {
16                 int temp=i;
17                 while(temp<len)
18                 {
19                       putchar(str[temp]);
20                       if(temp+2*n-1-i*2<len)
21                       putchar(str[temp+2*n-1-i*2]);
22                      //printf("%c%c",str[temp],str[temp+2*n-1-i*2]);
23                      temp=temp+2*n;;
24                 }
25           }
26           printf("\n");
27     }
28 }
原文地址:https://www.cnblogs.com/1114250779boke/p/2770838.html