#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
int n;
cin >> n;
string s = to_string(n);// 将整数转为字符串
string ret;
int count = 0;// 记录当前处理了多少位数字
// 从右向左遍历
for (int i = s.length() - 1; i >= 0; --i) {
ret.push_back(s[i]);
count++;
// 每三位添加一个逗号,且不是最后一位
if (count % 3 == 0 && i != 0) {
ret.push_back(',');
}
}
// 反转结果字符串
reverse(ret.begin(), ret.end());
cout << ret;
return 0;
}
// 64 位输出请用 printf("%lld")

京公网安备 11010502036488号