rafid_shad

uva new

Oct 17th, 2018
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     string name;
  6.  
  7.     while(getline(cin,name))
  8.     {
  9.         string a;
  10.         int m=0,i,j,k;
  11.         int len=name.length();
  12.         for(i=0; i<len; i++)
  13.         {
  14.             if(name[i]==' ')
  15.             {
  16.                 for(j=i-1,k=0; j>=m; j--,k++)
  17.                 {
  18.                     a[k]=name[j];
  19.                     cout<<a[k];
  20.                 }
  21.                 m=i+1;
  22.                 cout<<" ";
  23.  
  24.             }
  25.  
  26.         }
  27.         if(i==len)
  28.         {
  29.             for(j=i-1,k=0; j>=m; j--,k++)
  30.             {
  31.                 a[k]=name[j];
  32.                 cout<<a[k];
  33.             }
  34.  
  35.         }
  36.         cout<<endl;
  37.     }
  38.     return 0;
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment