原题:http://acm.hdu.edu.cn/showproblem.php?pid=1062
#include<stdio.h>
#include<string.h>
char s[1100];
char a[1100];
int main()
{
int cas;
scanf("%d", &cas);
getchar();
while(cas--)
{
gets(s);
int len = strlen(s);
int k = 0;
for(int i = 0;i<len;i++)
{
if(s[i]!=' ')
a[++k] = s[i];
else
{
for(int j = k;j>=1;j--)
printf("%c", a[j]);
printf(" ");
k = 0;
}
}
for(int j = k;j>=1;j--)
printf("%c", a[j]);
printf("\n");
}
return 0;
}