题解 | 添加逗号
添加逗号
https://www.nowcoder.com/practice/f51c317e745649c0900996fd3f683aed
#include <iostream>
#include<string>
using namespace std;
int main() {
string a;
cin >> a;
int c = 0;
string s;
for (int i=a.length()-1;i>=0;i--) {
c++;
s =a[i]+s;
if (c == 3) {
if (i != 0) {
s = ','+s;
}
c = 0;
}
}
cout << s;
}
// 64 位输出请用 printf("%lld")
查看2道真题和解析