题解 | #字符串分隔#

字符串分隔

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

遍历处理即可
第一步 先看可以输出几行
第二步 对于每行的8个元素进行判断 是添加0还是有初始值

import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNext()){
            String str = scanner.nextLine();
            int len = str.length();
            int num = (len + 7) / 8;
            int cnt = 0;
            while(num != 0){
                char[] ch = new char[8];
                for(int i = 0; i < 8; i++){
                    if(cnt < len){
                        ch[i] = str.charAt(cnt++);
                    }else{
                        ch[i] = '0';
                    }
                }
                System.out.println(new String(ch));
                num--;
            }
        }
    }
}
全部评论

相关推荐

lllllkin:感觉可以精简到一页简历,有些排版感觉不是必须的。 时间线越早的,你自己越熟悉的放前面。描述可以更精简些,一些问题解决感觉可以不用写具体技术栈,卖个关子,等面试官问。
点赞 评论 收藏
分享
程序员饺子:正常 我沟通了200多个 15个要简历 面试2个 全投的成都的小厂。很多看我是27直接不会了😅
点赞 评论 收藏
分享
在瑞幸干两年,奥特曼都得闪灯
不知名的牛友:奥特曼每天只上3分钟班
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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