View Code of Problem 101

#include<stdio.h>
#include<string.h>
int main()
{
	char str1[1000],str[1000],str2[1000];
	int i,j,k,l,len;
	gets(str1);
	len=strlen(str1);
	for(i=0;i<len;i++)
		if(str1[i]==','){
			for(j=i;j<len;j++)
				str1[j]=str1[j+1];	
		}
	len=strlen(str1);k=len%3;
	if(k==0) k+=3;	
	for(j=0;j<len;j++){
		if(j==k) {
			printf(",");
			k+=3;
		}
		printf("%c",str1[j]);
	}	
	
	printf("  %d  ",strlen(str1));	
	return 0;
}

Double click to view unformatted code.


Back to problem 101