View Code of Problem 101

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

Double click to view unformatted code.


Back to problem 101