View Code of Problem 114

#include<bits/stdc++.h>
using namespace std;

int main(void)
{
  string s,str;
  int i,j,flag;
  while(getline(cin,s))
  {
    flag=0;
    for(i=0;i<=s.size();++i)
    {
      if(s[i]!=' '&&i<s.size())
        str+=s[i];
      else
      {
        if(flag)
          cout<<" ";
        ++flag;
        for(j=str.size()-1;j>=0;--j)
          cout<<str[j];
        str="";
      }
    }
  }
}

Double click to view unformatted code.


Back to problem 114