View Code of Problem 114

#include<bits/stdc++.h>
using namespace std;
int main(){
	char s[1000],c[1000];
	int flag = 0;
	while(gets(s)){
		int len = strlen(s);
		for(int i = 0;i<len;i++){
			if(s[i] >='a' &&  s[i] <='z' || s[i] >='A' &&  s[i] <='Z'){
				flag = 0;
				while(s[i] >='a' &&  s[i] <='z' || s[i] >='A' &&  s[i] <='Z')c[flag++] = s[i++];
				i--;
				for(int i = flag - 1;i>=0;i--)cout<<c[i];
			}else{
				cout<<s[i];
			}	
		}
		cout<<endl;	
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 114