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)){
			int z=0;
			while(i<strlen(a)&&a[i]==' '){
			++i;
			cout<<" ";	
			}
			k=i;
			while(a[i]!=' '&&i<strlen(a)){
				++i;
			}
			
			j=i-1;
		//	while(a[i]==' '&&a[i+1]==' '&&i<strlen(a)){
		//		i++;
		//		z++;
		//	}
			
		//	if(i<strlen(a))
		//	++i;
			
			for(;j>=k&&i<=strlen(a);--j){
				cout<<a[j];
			}
			
			if(i>=strlen(a))
			cout<<endl;
		//	else
		//	for(;z>=0;--z)
		//	cout<<" ";
		}
		
	}
	
	
	return 0;
}

Double click to view unformatted code.


Back to problem 114