View Code of Problem 114

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main() {
	char a[1000];
	int i,j,r;
	while(gets(a)!=NULL){
		for(i=0;i<strlen(a);i++){
			r=0;
			if((a[i]>='a' && a[i]<='z')|| (a[i]>='A' && a[i]<='Z')){
				for(j=i;j<strlen(a);j++){
					if((a[j]>='a' && a[j]<='z')|| (a[j]>='A' && a[j]<='Z')){
						r++;
					}else{
						break;
					}
				}
				for(j=i+r-1;j>=i;j--){
					printf("%c",a[j]);
				}
				i=i+r-1;
			}
			else{
				printf("%c",a[i]);
			}
		}
		printf("\n");
	}
}

Double click to view unformatted code.


Back to problem 114