HDU 1062

#include<stdio.h>
#include<string.h>
char str[1001],temp[101],*p;
int main()
{
    int n,i,j;
    scanf("%d",&n);
    getchar();
    while(n--)
    {
        memset(str,0,sizeof(str));
        gets(str);
        p = str;
        i = 1;
        while(*p!='\0')
        {
            if(*p!=' ')
            {
                temp[i++] = *p;
                if(*(p+1)==' ')
                    temp[0] = ' ';
            }
            else
            {
                for(j = i -1;j >= 0;j  --)
                    printf("%c",temp[j]);
                    i = 1;
            }
            if(*(p+1)=='\0')
            {
                    for(j = i -1;j >0;j  --)
                    printf("%c",temp[j]);
            }
            p++;
        }
      printf("\n");
    }
    return 0;
}


posted on 2014-04-30 18:35  wangzhili  阅读(97)  评论(0编辑  收藏  举报