View Code of Problem 101

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

Double click to view unformatted code.


Back to problem 101