#include<stdio.h> #include<string.h> int main() { char s[100]; char t[100]; int i; while(scanf("%s",s)!=EOF) { int k=0; int z=0; int le_s=strlen(s); for(i=le_s-1;i>=0;i--) { if(s[i]>='0'&&s[i]<='9') { t[k]=s[i]; if((k+1-z)%3==0) { k++; t[k]=','; z++; } k++; } } t[k]='\0'; int le_t=strlen(t); for(i=le_t-1;i>=0;i--) printf("%c",t[i]); printf("\n"); } return 0; } |
Double click to view unformatted code.