题解 | #字符串分隔#

字符串分隔

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

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder(sc.next());
        int len = sb.length();
        int a = 0;
        int b = 8;
        while (len>8) {
            System.out.println(sb.substring(a, b));
            a=a+8;
            b = b + 8;
            len = len - 8;
        }
        sb.append("00000000");
        System.out.print(sb.substring(a,b));
    }}

全部评论

相关推荐

评论
点赞
收藏
分享
牛客网
牛客企业服务