View Code of Problem 101

#include <stdio.h>
#include <string.h>
int main(){
  char a[100];
  char b[100];
  int i,j=0,k=0;
  while (gets(a)!= NULL){
    for(i=strlen(a)-1;i>=0;i--){
      if(a[i] !=','){
        if(k==3){
          b[j++]=',';
          k=0;
        }
        b[j++]=a[i];
        k++;
      }
    
    
    }
    j--;
    for(i=0;j>=0;i++,j--)
      a[i]=b[j];
    a[i]='\0';
    puts(a);
	
    j=0;k=0;
    for(i=0;i<100;i++)
      a[i]=b[i]=NULL;
    
    
  
  
  
  }


return 0;
}

Double click to view unformatted code.


Back to problem 101