#include<iostream> #include<algorithm> using namespace std; int main() { string s; while(cin>>s){ reverse(s.begin(),s.end()); string tmp; int count=0; for(int i=0;i<s.length();++i){ if(s[i]>='0'&&s[i]<='9'){ tmp+=s[i]; count++; if(count==3){ if(i!=s.length()-1){ tmp+=','; count=0; } } } } reverse(tmp.begin(),tmp.end()); cout<<tmp<<endl; tmp.clear(); } } |
Double click to view unformatted code.