#include <stdio.h> #include <stdlib.h> #include<ctype.h> #include<string.h> #include<math.h> #include<stdbool.h> int main() { int i, j, n; char a[20], b[20]; while (gets(a)) { n = 0; for (i = strlen(a) - 1, j = 0; i >= 0; i--) { if(isalnum(a[i])) { if (n % 3 == 0&&n!=0) b[j++] = ','; n++; b[j++] = a[i]; } } for (i = j - 1; i >= 0; i--) { printf("%c", b[i]); } printf("\n"); } return 0; } |
Double click to view unformatted code.