View Code of Problem 101

#include<stdio.h>
#include<string.h>
#include<math.h>
	
int main(){
 


		char a[1000];
		char b[1000];
		while(gets(a)){
			int k=0,w=0;
			for(int i=strlen(a)-1;i>=0;i--){
			
				if(a[i]>='0'&&a[i]<='9'){
					b[k]=a[i];
					k++;
					w++;
				}
				if(w==3){b[k]=',';k++;w=0;}
				
			}
		


			for(int j=k-1;j>=0;j--)
			{
				printf("%c",b[j]);
			
			}
		printf("\n");
		}
}
	

Double click to view unformatted code.


Back to problem 101