题解 | #添加逗号#

添加逗号

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

#include <stdio.h>
#include<string.h>
#define NUM 2000000
int main()
{
    char str[NUM] = { 0 };
    //输入
    while (~scanf("%s", str))
    {
        int len = strlen(str);
        int cnt = len;//计数器
        //输出
        for (int i = 0; i < len; i++, cnt--)
        {
            if (cnt % 3 == 0 && cnt != len)
            {
                printf(",");
            }
            printf("%c", str[i]);
        }
        
    }
    return 0;
}

全部评论

相关推荐

03-04 07:14
门头沟学院 C++
黑皮白袜臭脚体育生:老板:都给工作机会了还想要工资,哪来这么多好事
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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