View Code of Problem 114

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main (){
	char s[1010];
	while(gets(s)){
		for(int i = 0;i < strlen(s);i++){
			if(isalpha(s[i])){
				int k = 1;
				for(int j = i+1;j < strlen(s);j++){
					if(isalpha(s[j])) k++;
					else break;
				}
				for(int j = k+i-1;j >= i;j--){
					printf("%c", s[j]);
				}
				i = i+k-1;
			}else printf("%c", s[i]);
		}
		printf("\n");
	}

	return 0;
}

Double click to view unformatted code.


Back to problem 114