OD4 | 字符串分隔
字符串分隔
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);
        //接收字符串
        String  str = sc.nextLine();
        //在8个字符之间进行分割,留下最后分割的部分
        for (int i = 0; i < str.length()/8; i++) {
            System.out.println(str.substring(i*8,(i+1)*8));
        }
        //最后一部分就不用println,用print,因为要补0不能换行
        System.out.print(str.substring(str.length()/8*8));
        //如果最后一部分的长度不是8的倍数,补0
        if(str.length()%8!=0){
            int mod=str.length()%8;
            for (int i = 0; i < 8-mod; i++) {
                System.out.print("0");
            }
        }
    }
}
 投递大连飞创信息技术有限公司等公司10个岗位
投递大连飞创信息技术有限公司等公司10个岗位 基恩士成长空间 419人发布
基恩士成长空间 419人发布