首页 > 代码库 > PAT Basic Level 1009

PAT Basic Level 1009

AC 代码

 1 #include <stdio.h>
 2 int main()
 3 {
 4     char string[100];
 5     gets(string);           //这条是重点,注意与scanf(%s)的不同
 6     int size = 0;
 7     while(string[size] != \0)
 8     {
 9         size++;
10      } 
11      int flag = size ;
12     while (flag != 0)           //开始 
13     {
14         
15          do                   //此处用WHILE 就不行 
16          {
17              flag--;
18          }while(string[flag] !=  &&flag != 0);
19          int temp = flag;
20          if(flag != 0)
21          {
22              while(flag != size-1)
23              {
24                  printf("%c",string[++flag]);
25              }
26              printf(" ");
27         }else
28         {
29             while(flag != size)
30             {
31                 printf("%c",string[flag++]);
32             }
33         }
34          size = temp;
35          flag = temp;
36          
37     }
38     
39     return 0 ;
40  } 

 

PAT Basic Level 1009