#include<iostream> #include<cstring> using namespace std; int main() { char str[100],num[100]; while(gets(str)) { int j=0; for(int i=0; str[i]!='\0'; i++) { if(str[i]!=',') num[j++]=str[i]; } num[j]='\0'; int k=strlen(num)%3; for(int i=0; i<k; i++) cout<<num[i]; for(int i=k,j=0; num[i]!='\0'; i++,j++) { if(j%3==0&&i>0) cout<<','<<num[i]; else cout<<num[i]; } cout<<endl; } return 0; } |
Double click to view unformatted code.