Advertisement
immuntasir

UVA 483

Feb 15th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.95 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. int main()
  4. {
  5.     int len;
  6.     char ara[1000];
  7.     while(gets(ara)) {
  8.         int j,x,k;
  9.  
  10.  
  11.         len=strlen(ara);
  12.         int i =0;
  13.         x = i -1;
  14.  
  15.         /* ekhane amra ekta loop chaliye check korbo space ache naki..
  16.         jekhane space pabo, tar ek ghor aage theke last jekhane space paichilam, tar ek ghor por
  17.         porjonto print korbo */
  18.  
  19.         for(i=0;i<len;i++) {
  20.             if(ara[i]==' ') {
  21.                 for(j=i-1;j>x;j--) {
  22.                     printf("%c",ara[j]);
  23.                 }
  24.                 printf(" ");
  25.                 x=i;
  26.             }
  27.         }
  28.  
  29.         /*  eta last word tar jonno.. karon aage loop tar moddhe
  30.         amra jei space khujchi, oita last word ar er aager moddhei ache..
  31.          nicher ta na likhle tai last word print hobe na.. */
  32.  
  33.         for(i=len-1;i>x;i--){
  34.             printf("%c",ara[i]);
  35.         }
  36.     printf("\n");
  37.     }
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement