View Code of Problem 101

#include<stdio.h> 
#include<string.h>
#include<math.h>

int main(){
    int i,j,k;
    char s[100],a[100];
    while(~scanf("%s",s)){
    	int len=strlen(s);
    	int m=0;
    	k=0;
    	for(i=len-1;i>=0;i--){
    		if(s[i]!=','){
    			a[k++]=s[i];
    			m++;
			} 
			if(m==3&&i!=0){
				a[k++]=',';
				m=0;
			}
		}
		for(i=k-1;i>=0;i--){
			printf("%c",a[i]);
		}
		printf("\n");
	}
    return 0; 
     
}

Double click to view unformatted code.


Back to problem 101