HDU 1062 Text Reverse(水题)

来源:互联网 发布:c语言中const的用法 编辑:程序博客网 时间:2024/06/05 20:48

没事水一水。

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1062

<pre name="code" class="cpp">#include<stdio.h>#include<string.h>int main(){    int t;    char s[1005];    scanf("%d",&t);    getchar();    while(t--)    {        memset(s,0,sizeof(s));        gets(s);        int l=strlen(s);        int pos=0,q=0;        for(int i=0; i<=l; i++)        {            if(s[i]==' '||i==l)            {                for(int j=i-1; j>=i-pos; j--)                    printf("%c",s[j]);                if(s[i]==' ')                    printf(" ");                pos=0;            }            else                pos++;        }        printf("\n");    }    return 0;}



1 0