View Code of Problem 101

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

Double click to view unformatted code.


Back to problem 101