View Code of Problem 101

#include "stdio.h"
#include "string.h"
#include "ctype.h"
#include "math.h"
int main()
{
    int t,n,x,i,j,cnt;
  	char a[100],b[100];
  	while(gets(a)!=NULL)
  	{
  		cnt=0,j=0;
  		for(i=strlen(a)-1;i>=0;i--)
  		{
  			if(a[i]!=',')
  			{
  				b[j++]=a[i];cnt++;
  				if(cnt==3)
  				{
  					b[j++]=',';
  					cnt=0;
  				}
  			}
  		}
  	    j--;
		for(i=0;j>=0;i++,j--)
		{
			a[i]=b[j];
		}
		printf("%s\n",a);
  	   memset(a,NULL,sizeof(a));
  	   memset(b,NULL,sizeof(b));
  	}
    return 0;
}

Double click to view unformatted code.


Back to problem 101