View Code of Problem 114

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

Double click to view unformatted code.


Back to problem 114