题解 | #字符串分隔#
字符串分隔
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);
Scanner input = new Scanner(System.in);
while (input.hasNext()) {
int i1 = 0;
String str = null;
str = input.nextLine();
int num = str.length();
i1 = num / 8;
if (8 * i1 < num) {
i1 = i1 + 1;
int count = i1 * 8 - num;
for (int i = 0; i < count; i++) {
str = str + "0";
}
} else {
i1 = i1 + 0;
}
for (int i = 0; i < i1; i++) {
//substring返回[index,endIndex-1]
String substring = str.substring(8 * i, 8 * i + 8);
System.out.println(substring);
}
}
}
}

凡岛公司福利 297人发布