#include<bits/stdc++.h> using namespace std; int main(){ char s[100],a[100]={0}; while(gets(s)){ int k=0,count=0; for(int i = strlen(s)-1; i >= 0; i--){ if(s[i]!=','){ a[k] = s[i]; k++; count++; if(count==3&&i!=0){ a[k] = ','; k++; count = 0; } } } for(int i = k-1; i >= 0; i--){ cout<<a[i]; } cout<<endl; } } |
Double click to view unformatted code.