题解 | #添加逗号#

添加逗号

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

#include <stdio.h>
#include <string.h>

#define N 15

char a[N];
char b[N * 2];

int main()
{
    scanf("%s", a);

    int k = 0;
    for (int i = strlen(a) - 1, j = 1; i >= 0; i -- , j ++ )
    {
        b[k ++ ] = a[i];
        if (j == 3 && i)
        {
            b[k ++ ] = ',';
            j = 0;
        }
    }

    for (int i = strlen(b) - 1; i >= 0; i -- ) printf("%c", b[i]);

    return 0;
}

全部评论

相关推荐

码农索隆:这种hr,建议全中国推广
点赞 评论 收藏
分享
uu们,拒offer时hr很生气怎么办我哭死
爱睡觉的冰箱哥:人家回收你的offer,或者oc后没给你发offer的时候可不会愧疚你,所以你拒了也没必要愧疚他。
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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