View Code of Problem 101

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

Double click to view unformatted code.


Back to problem 101