View Code of Problem 114

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

	return 0;
}

Double click to view unformatted code.


Back to problem 114