View Code of Problem 101

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

Double click to view unformatted code.


Back to problem 101