View Code of Problem 101

#include<stdio.h>
#include<string.h>
int main()
{
	char str[100],sti[100];
	int i,count=0,n=0;
	while(gets(str)!=NULL)
	{
		for (i=strlen(str)-1;i>=0;i--)
		{
			if(str[i]!=',')
			{
				if(count==3)
				{ 
				sti[n++]=',';
				count=0;
			}
			sti[n++]=str[i];
			count++;
		}
	}
	n--;
	for(i=0;n>=0;n--,i++)
		str[i]=sti[n];
	printf("%s\n",str);
	n=count=0;
	for(i=0;i<100;i++)
		str[i]=sti[i]=NULL;
}
return 0;
}

Double click to view unformatted code.


Back to problem 101