View Code of Problem 101

#include<stdio.h>
#include<string.h>
int main()
{
char s[1000];
int n,i,j=0,m=0,l,k;
while(scanf("%s",s)!=NULL)
{
n=strlen(s);
for(i=0;i<n;i++)
{if(s[i]>='0'&&s[i]<='9')
s[j++]=s[i];
}
s[j]='\n';
k=j%3;l=j/3;
for(i=0;i<k;i++)
printf("%c",s[i]);
if(k!=0)
printf(",");
for(i=k;i<j;i++)
{
printf("%c",s[i]);
m++;
if(m%3==0&&m/3!=l)
printf(",");
}
m=0;j=0;
printf("\n");
}
}

Double click to view unformatted code.


Back to problem 101