#include<string> #include<iostream> #include<algorithm> using namespace std; int main() { string a,b; while (cin >> a) { while (a.find(',') != -1) { a.erase(a.find(','), 1); } int k = a.size() % 3; int i; if (k == 0) { for (i = 0; i < a.size(); i++) { cout << a[i]; } } else { for (i = 0; i < k; i++) { cout << a[i]; } while (i < a.size()) { printf(","); int num = 3; while (num--) { cout << a[i]; i++; } } } cout << endl; } return 0; } |
Double click to view unformatted code.