View Code of Problem 101

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

Double click to view unformatted code.


Back to problem 101