UVa 483 - Word Scramble

#include<stdio.h>
#include<string.h>
 
int main()
{
    char s[1000000];
    int n,i,j,ans[12];
    while(gets(s))
    {
        int l=-1,h;
        for(i=0;i<=strlen(s);i++)
        {
            if(s[i]==' ' || s[i]=='\0')
            {
                for(j=h;j>=l;j--)
                    printf("%c",s[j]);
                if(h!=strlen(s)-1)
                    printf(" ");
                l=-1;
            }
            else
            {
                if(l==-1)
                    l=i;
                h=i;
            }
        }
        printf("\n");
    }
    return 0;
}
Share on Google Plus

About Unknown

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 মন্তব্য(গুলি):

একটি মন্তব্য পোস্ট করুন