题解 | #字符串分隔#

字符串分隔

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));
        }
    }
}
全部评论

相关推荐

求offer的大角牛:不吃香菜
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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