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[1000],b[1000];
  	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;
  				}
  			}
  		}
  	   for(i=j-1;i>=0;i--)
  	   {
  	   	 if(i>0)
			printf("%c",b[i]);
		 else
		    printf("%c\n",b[i]);
  	   }
  	}
    return 0;
}

Double click to view unformatted code.


Back to problem 101