View Code of Problem 114

#include<iostream>
#include<string>
#include<cctype> 
#include<cstdio> 
using namespace std;
int main()
{
    string sp,ans;
    while( getline(cin,sp) )
    {
        int i;
        for( i=0;i<sp.size();i++ )
        {
            if( isalpha(sp[i]) )
            {
                ans=sp[i]+ans;
            }else
            {
                cout<<ans<<sp[i];
                ans.clear();
            }
        }cout<<ans<<endl;
        ans.clear();
    }
    	return 0;   
}

Double click to view unformatted code.


Back to problem 114