#include<bits/stdc++.h> using namespace std; typedef long long ll; int main (){ char s[1010]; while(gets(s)){ char str[1010]; int k = 0, cnt = 0; for(int i = strlen(s)-1;i >= 0;i--){ if(s[i]>='0'&&s[i]<='9'){ str[k++] = s[i]; cnt++; } if(cnt%3==0&&cnt) str[k++] = ','; } for(int i = k-1;i >= 0;i--){ printf("%c", str[i]); } printf("\n"); } return 0; } |
Double click to view unformatted code.