华为机试-字符串分割(HJ104)-纯C

字符串分割

https://www.nowcoder.com/practice/fa2e02625a8541beb2309fcb7ab31e5b?tpId=37&&tqId=21327&rp=1&ru=/ta/huawei&qru=/ta/huawei/question-ranking

纯C

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

int main()
{
    int n=0;
    while(scanf("%d", &n) != EOF)
    {
        char str[100] = {'\0'};
        for(int i=0; i<n; i++)
        {
            scanf("%s", str);
            int len=strlen(str);
            char *pstr = str;
            while(len > 8)
            {
                for(int i=0; i<8; i++)
                {
                    printf("%c", *(pstr++));
                }
                printf("\n");
                len -= 8;
            }
            printf("%s", pstr);
            len = 8-len;
            while(len)
            {
                printf("0");
                len--;
            }
            printf("\n");
        }
    }
    return 0;
}
全部评论

相关推荐

10-29 19:45
吉林大学 Java
从零开始数:自我评价没有必要写,但是看起来你应该是学了csdiy的一些课程,可以在专业技能里面写上自己比较熟悉操作系统和计网,但如果你是找Java的话,把第一个项目换了吧,现在看起来有点四不像。 无论是黑马点评或者说做个轮子项目,刷题和八股也搞起来吧,而且也没必要等到寒假,最近就可以开始找,找到就偷偷实习呗,别被逮到就行了。
点赞 评论 收藏
分享
11-13 12:02
门头沟学院 Java
我要娶个什么名:好骂,好骂 别学计算机就行了
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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