题解 | #字符串分隔#

字符串分隔

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

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.nextLine();
        // 计算要补充的0的个数
        int zeroNum = str.length() % 8 == 0 ? 0 : 8 - str.length() % 8;
        str += String.join("", Collections.nCopies(zeroNum, "0"));
        for (int i = 0; i < str.length(); i += 8) {
            System.out.println(str.substring(i, i + 8));
        }
    }
}

#华为笔试#
全部评论
这是今天的笔试题目嘛
点赞 回复 分享
发布于 2022-09-28 20:47 瑞典

相关推荐

不愿透露姓名的神秘牛友
07-11 11:22
怎么这么多逆天求职者,救救我救救我救救我😭
flmz_Kk:哈哈哈哈哈哈,这么多求职者,肯定有那一两个逆天的
点赞 评论 收藏
分享
仁者伍敌:牛子这些人还会点一个自动回复,boss都不带回复的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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