View Code of Problem 114

#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	string s;
	while(getline(cin,s)){
		string temp="";
		for(int i=0;i<s.length();++i){
			if(s[i]==' '){
				reverse(temp.begin(),temp.end());
				cout<<temp;
				temp="";
				cout<<s[i];
			} else {
				temp+=s[i];
			}
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 114