View Code of Problem 101

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

Double click to view unformatted code.


Back to problem 101