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]>='0'&&a[i]<='9')
  	   	 {
  	   	 	b[j++]=a[i];
  	   	 	cnt++;
  	   	 	if(cnt==3)
  	   	 	{
  	   	 		b[j++]=',';
  	   	 		cnt=0;
  	   	 	}
  	   	 }
  	   }
  	   j--;
  	   for(i=j;i>=0;i--)
  	     printf("%c",b[i]);
  	     printf("\n");
  	    
  	    memset(a,0,sizeof(a));
  	    memset(b,0,sizeof(b));
  	}
  	
  
  	   
  
    return 0;
}

Double click to view unformatted code.


Back to problem 101