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] != ' ') cnt++;
			else{
				for( int j=i-1; j>= i-cnt;j-- ){
					printf("%c", ch[j]);
				}
				cnt = 0;
				printf("%c", ch[i]);
			}
		}
		printf("\n");
	}

	return 0;
	
}

Double click to view unformatted code.


Back to problem 114