题解 | #字符串分隔#

字符串分隔

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

import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        StringBuilder nextLine = new StringBuilder(scanner.nextLine());
        if (" ".equals(nextLine.toString().trim()) ||
                nextLine.toString().trim().length() == 0) {
            return;
        }
        if (nextLine.length() % 8 != 0) {
            int addZeroNumber = nextLine.length() % 8;
            for (int i = 0; i < (8 - addZeroNumber); i++) {
                nextLine.append("0");
            }
        }
        for (int i = 0; i < nextLine.length(); i += 8) {
            System.out.println(nextLine.substring(i, i + 8));
        }
    }
}
全部评论

相关推荐

码农索隆:单休一个月少休息4天,一年就是48天,平时节假日,别人3天假期,单休的两天
点赞 评论 收藏
分享
05-29 22:11
门头沟学院 Java
Elastic90:抛开学历造假不谈,这公司的招聘需求也挺怪的,Java开发还要求你有图文识别、移动端开发和c++的经验,有点逆天了。
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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