View Code of Problem 101

#include <stdio.h>
#include <string.h>
int isp(int n){
	return n<='9'&& n>='0';
}
int main(){
	
	char str[10000],a[10000];
	while(gets(str)){
		int c,k=0,n,i,j=0,len;
		memset(a,0,sizeof(a));
		len=strlen(str);
		for(i=len-1;i>=0;i--)		
			if(isp(str[i])){
				a[j++]=str[i];k++;
				if(k%3==0&&i!=0){	
					k=0;
					a[j++]=',';	
				}
			}
		
			 
			
		
		len=strlen(a);
		for(i=len-1;i>=0;i--) 
			printf("%c",a[i]);
		printf("\n");
	}
	
	return 0;
} 

Double click to view unformatted code.


Back to problem 101