杭电acm1321

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

这题只需反过来输出就可以了,我这里的代码是改自UVA的483

View Code
 1 #include<stdio.h>  
 2 #include<stdlib.h>
 3 #include<string.h>
 4 void shuchu(char *s,int *i)//当不是空格是倒序输出
 5 {
 6  char temp[100];
 7  int j=0,k;
 8  while((*s)!=32&&(*s)!='\0')
 9     {
10      temp[j++]=*s--;
11      (*i)--;
12     }
13     j--;
14  for(k=0;k<=j;k++)
15     printf("%c",temp[k]);
16 }
17 int main()
18 {
19  int i,t;
20  char str[10000];
21  scanf("%d",&t);
22  gets(str);
23  while(t--)
24      {
25      gets(str);
26       for(i=strlen(str)-1;i>=0;i--)
27          {
28           if(str[i]!=32)
29              {
30               shuchu(&str[i],&i);
31               i++;//在自定义函数中自加了一,考虑到循环中的自加一,这里要减一 
32              }
33           else printf("%c",str[i]);//遇到空格直接输出
34          }
35        printf("\n");
36      }
37  return 0;
38 }
原文地址:https://www.cnblogs.com/huzhenbo113/p/3027074.html