View Code of Problem 101

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main() {
	char a[1000],b[1000],c[1000];
	while(scanf("%s",&a)!=EOF){
	
	int j=0,i,k;
	for(i=0;i<strlen(a);i++){
		if(a[i]>='0' && a[i]<='9'){
			b[j++]=a[i];
		}
	}
	int count=0;
	for(i=j-1,k=0;i>=0;i--){
		c[k++]=b[i];
		count++;
		if(count%3==0 && count!=0 && i!=0){
			c[k++]=',';
		}
		
	}
	for(i=k-1;i>=0;i--){
		printf("%c",c[i]);
	}
	printf("\n");
	}
}

Double click to view unformatted code.


Back to problem 101