View Code of Problem 114

#include<iostream>
#include<cstring>
using namespace std;
int main(){
	char a[1000];
	
		while(gets(a)!=NULL){
		int i=0,j=0,k=0;
		while(i<strlen(a)){
			while(a[i]==' ')
			++i;
			while(a[i]!=' '&&i<strlen(a))
			++i;
			j=i-1;
			while(a[i]==' '&&a[i+1]==' '&&i<strlen(a))
			i++;
			if(i<strlen(a))
			++i;
			
			for(;j>=k;--j){
				cout<<a[j];
			}
			k=i;
			if(i>=strlen(a))
			cout<<endl;
			else
			cout<<" ";
		}
		
	}
	
	
	return 0;
}

Double click to view unformatted code.


Back to problem 114