翻转吧,字符串

http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2085

View Code
 1 #include<stdio.h>
 2 #include<string.h>
 3 int main()
 4 {
 5     char str[300] ;
 6     int i, j,k, t, n,iq, len ;
 7     scanf("%d", &t);
 8     getchar() ;
 9     for(iq=0; iq<t; iq++)
10     {
11         gets(str);
12         len = strlen(str) ;
13         printf("Case %d:", iq+1) ;
14         i = j = len -1 ;
15         while(i>=0)
16         {
17             if(i==0)
18             for(k=i; k<=j; k++)  printf("%c", str[k]) ;
19             if(str[i]==' ')
20             {
21                 for(k=i+1; k<=j; k++) printf("%c", str[k]) ;
22                 printf(" ") ;
23                 j = i - 1 ;//注意思考
24             }
25             i-- ;
26         }
27         printf("\n") ;
28      }
29      return 0 ;
30 }

多思考

原文地址:https://www.cnblogs.com/yelan/p/2878109.html