View Code of Problem 101

#include <stdio.h>
#include <string.h>
#include <math.h>
#define N 100000
int main()
{
	char a[N];
	int i;
	while(scanf("%s",&a)!=EOF)
	{
		char b[N];
		int lenth=strlen(a);
		int j=0;
		int count=0;
		for(i=lenth-1;i>=0;i--)
		{
			if(a[i]!=',')
			{
				b[j++]=a[i];
				count++;
			}	
			if(count%3==0&&i!=0)
				b[j++]=',';
		}	
		for(i=j-1;i>=0;i--)
			printf("%c",b[i]);
		printf("\n");
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 101