题解 | #字符串分隔#

字符串分隔

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

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

int main() {
    char str[100];
    int cnt = 0;
    while (scanf("%s", str) != EOF) { //循环输入
        int len = strlen(str);
        int i;
        for (i = 0; i < len; i++) {
            if (i > 0 && i % 8 == 0) { //按8分割
                printf("\n");
                cnt = 0;
            }
            printf("%c", str[i]);
            cnt++;  //计数

        }
        while (cnt < 8) { //不够补0
            printf("0");
            cnt++;
        }

        printf("\n");

    }

    return 0;
}

C语言刷题 文章被收录于专栏

自己从头开始刷的C语言

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-08 17:10
点赞 评论 收藏
分享
昨天 12:22
门头沟学院 Java
点赞 评论 收藏
分享
06-08 22:25
门头沟学院 Java
从零开始的转码生活:这hr不会打开手机不分青红皂白给所有人群发这句话,过一会再给所有人再发一遍,这肯定会有重复的,不管,再过一会再发一遍
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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