#include<iostream> #include<cstring> #include<math.h> using namespace std; int main(){ string s; while(cin>>s){ string m; int k=0; for(int i=0;i<s.length();i++){ if(s[i]!=',') m[k++]=s[i]; } string n; int j=0,num=0; for(int i=k-1;i>=0;i--){ num++; n[j++]=m[i]; if(num%3==0&&i!=0){ n[j]=','; j++; } } for(int i=j-1;i>=0;i--){ cout<<n[i]; } cout<<endl; } return 0; } |
Double click to view unformatted code.