View Code of Problem 101

#include<stdio.h>
#include<string.h>

int main()
{
  char a[100],b[100];
  int i,n;
  while(scanf("%s",a)!=EOF)
  {
    int k=0,count=0; 

    for(i=strlen(a)-1;i>=0;i--)
    {
      if(a[i]!=',')
      {
        if(count!=3)
        {
          b[k++]=a[i];
          count++;
        }
        else 
        {
          b[k++]=',';
          i++;
          count=0;
        }
      }   
    }
    for(i=k-1;i>=0;i--)
      printf("%c",b[i]);
    printf("\n");
  }
  return 0;
}

Double click to view unformatted code.


Back to problem 101