View Code of Problem 101

#include<stdio.h>
#include<string.h>
#include <math.h>
#define Max 1000
int main()
{
	int i,j,k,cnt;
	char a[Max],b[Max];
	while(gets(a)!=NULL)
	{
		cnt=0,j=0;
		for(i=strlen(a)-1;i>=0;i--)
		{
			if(a[i]!=',')
			{
				if(cnt==3)
				{
					b[j++]=',';
					cnt=0;
				}
				b[j++]=a[i];
			    cnt++;
			}
			
		}
		j--;//huishuo
		for(i=0;j>=0;i++,j--)
		{
			a[i]=b[j];
		}
		printf("%s\n",a);
		
		for(i=0;i<Max;i++)
		   a[i]=b[i]=NULL;
		  
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 101