View Code of Problem 101

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

Double click to view unformatted code.


Back to problem 101