题解 | #添加逗号#

添加逗号

https://www.nowcoder.com/practice/f51c317e745649c0900996fd3f683aed

 #include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
    string str;
    cin >> str;
    string retstr;
    size_t len = str.size();
    for(int i = 0;i < len ;i++)
    {
        retstr += str[i];
        if((len-i-1)%3 == 0 && i != len-1)
            retstr += ',';
    }
    cout << retstr << endl;
    return 0;
}

全部评论

相关推荐

缒梦&独舞:这家公司是这样的,去年给我实习offer了,不过也是面着玩儿的,他周六还要去做公益志愿活动
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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