View Code of Problem 114

#include<stdio.h>
#include<string.h>
int main(){
	char a[1000];
	while(gets(a)){ 
	int ct=0,bt=0,p=0,w;
	char c[1000][1000];
	char b[1000];
	char t;
	int len=strlen(a);
	a[len]=' ';
	for(int i=0;i<=len;i++){
		if(a[i]!=' '){
			c[bt][ct]=a[i];
			ct++;
		}
		else{
			bt++;
			b[p]=ct;
			p++;
			ct=0;
		}
	}
	for(int j=0;j<bt;j++){
		w=b[j];
		for(int k=0;k<(w/2);k++){
			t=c[j][k];
			c[j][k]=c[j][w-1-k];
			c[j][w-1-k]=t;
		}
	}
	for(int k=0;k<bt;k++){
		p=b[k];
		for(int z=0;z<p;z++){
			printf("%c",c[k][z]);
		}
		if(k!=(bt-1))
		printf(" ");
	} 
	printf("\n");
	}
}

Double click to view unformatted code.


Back to problem 114