#include <iostream> #include <cstdio> #include <cstring> #include <iomanip> using namespace std; int main(){ char a[999],b[999],c[999]; int t=0,j = 0,m = 0; while(cin.getline(a,999)){ t = 0,m = 0,j = 0; for(long int i=0;i<strlen(a);i++){ if(a[i]!=','){ b[t]=a[i]; t++; } } for(long int i=strlen(b)-1;i>=0;i--){ if(m%3==0&&m!=0){ c[j++]=','; } c[j++] = b[i]; m++; b[i]=NULL; } for(int i=j-1;i>=0;i--){ cout<<c[i]; c[i]=NULL; } cout<<endl; } return 0; } |
Double click to view unformatted code.