题解 | 添加逗号

添加逗号

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")

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务