View Code of Problem 101

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

Double click to view unformatted code.


Back to problem 101