View Code of Problem 114

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

int main() {

	string s;
	while(getline(cin,s)) {
		for(int i=0; i<s.length(); i++) {
			int j=i;
			while(((s[j]>='a'&&s[j]<='z')||(s[j]>='A'&&s[j]<='Z'))&&j<s.length()){
				j++;
			}
			reverse(s.begin()+i,s.begin()+j);
			i=j;
		}
		cout<<s<<endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 114