#include<bits/stdc++.h> using namespace std; int main() { string str; vector <char> a; vector <char> b; while(getline(cin,str)){ for(int i = 0; i < str.size(); i++){ if(str[i] <= '9' && str[i] >= '0'){ a.push_back(str[i]); } } int count = 0; for (int i = a.size()-1; i >= 0 ; i--){ count++; if(count % 3 == 0 && i != 0){ b.push_back(a[i]); b.push_back(','); } else b.push_back(a[i]); } for(int i = b.size() - 1; i >= 0; i--){ cout<< b[i]; } cout<<endl; a.clear(); b.clear(); } return 0; } |
Double click to view unformatted code.