View Code of Problem 101

#include<stdio.h>
int main()
{
	char str[100];
	while(scanf("%s",str)!=EOF)
	{
		char a[100],b[100];
		int s=0,k,i,j,x=1;
		for(i=0;str[i]!='\0';i++)
		{
			if(str[i]>='0'&&str[i]<='9')
			{
				a[s]=str[i];
				s++;
			}	
	    }
    
	    j=s-1;
		k=(s+1)/3;
		for(i=s+k-1;i>=0;i--)
		{
		   if(x%4==0)
		   b[i]=',';
			else
			{
				b[i]=a[j];
				j--;
			}
			x++;
		}
		printf("%s\n",b);
		
	} 
	return 0;
}

Double click to view unformatted code.


Back to problem 101