#include<stdio.h> #include<string.h> void main() { char a[1000]; char b[1000]; while (scanf("%s",a)!=EOF) { int len = strlen(a); int c = 0, t = 1; for (int i = len-1; i >= 0; i--) { if (a[i] == ',') continue; else { b[c++] = a[i] ; } if ((t++) % 3 == 0 && i != 0) { b[c++] = ','; } } for (int i = c-1; i >=0; i--) { printf("%c", b[i]); } printf("\n"); } } |
Double click to view unformatted code.