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