题解 | #字符串分隔#

字符串分隔

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

相关推荐

不愿透露姓名的神秘牛友
昨天 11:15
点赞 评论 收藏
分享
05-14 20:34
门头沟学院 Java
窝补药贝八股:管他们,乱说,反正又不去,直接说680
点赞 评论 收藏
分享
07-07 12:47
门头沟学院 Java
码农索隆:竟然还真有卡体检报告的
点赞 评论 收藏
分享
小叮当411:应该是1-3个月吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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