View Code of Problem 114

#include <stdio.h>
#include <string.h>
using namespace std;
int main(){
	
	char ch[1000];
	while( gets(ch) != NULL ){
		int cnt = 0;
		for( int i=0; i<strlen(ch); i++ ){
			if( ch[i]>='a' && ch[i]<='z' || ch[i]>= 'A' && ch[i]<='Z'){
				cnt=1;
				for( int j=i+1;j<strlen(ch); j++ ){
					if( ch[j]>='a' && ch[j]<='z' || ch[j]>= 'A' &&ch[j]<='Z'){
						cnt ++;
					}else{
						break;
					}
				}
				for( int j=i+cnt-1;j>=i; j-- ){
					printf("%c", ch[j]);
				}
				i=i+cnt-1;
			}else{
				printf("%c", ch[i]);
			}
		}
		printf("\n");
	}

	return 0;
	
}

Double click to view unformatted code.


Back to problem 114