View Code of Problem 114

#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	char a[100],b[100];
	int l,k=0;
	while(gets(a)!=NULL){
		l=strlen(a);
		for(int i=0;i<=l;i++){
			if(a[i]!=' '&&a[i]!='\0'){
				b[k]=a[i];
				k++;
			}
			else if(a[i]==' '){
				for(int j=k-1;j>=0;j--){
					printf("%c",b[j]);
				}
				printf(" ");
				k=0;
			}
			else if(a[i]=='\0'){
				for(int j=k-1;j>=0;j--){
					printf("%c",b[j]);
				}
				k=0;
				printf("\n");
			}
		}
		
	}
}

Double click to view unformatted code.


Back to problem 114