题解 | #字符串分隔#

字符串分隔

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

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

int main() {
    char str[100];
    while (scanf("%s", str) != EOF) 
    {
        int n = strlen(str);
        for(int i = 0; i < n; i++)
        {
            printf("%c", str[i]);
            if((i + 1) % 8 == 0)
                printf("\n");
        }
        int m = n % 8;
        if(m)
        {
            for(int i = 0; i < 8 - m; i++)
            {
                printf("%c", '0');
            }  
            printf("\n");
        }
     
    }
    return 0;
}

全部评论

相关推荐

03-26 12:00
已编辑
门头沟学院 Java
offer魅魔_oc...:100-200每天,你还要倒贴100
点赞 评论 收藏
分享
03-26 19:49
吉林大学 Java
elliot19:确实是这样,上次就纯聊天,问项目实习做啥,最后掏了一道非hot100的hard第二天挂,今晚复活重新一面
查看6道真题和解析
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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