View Code of Problem 101

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

Double click to view unformatted code.


Back to problem 101