- 输入放list
- 遍历list
- 对于每一个字符串,对8取整,有余数的加1 ,遍历次数,每次就打印8个,不够的0补充
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
List<String> array = new ArrayList<>();
while (in.hasNextLine()) { // 注意 while 处理多个 case
array.add(in.nextLine().trim());
}
for (int i = 0; i < array.size(); i++) {
char[] charArray = array.get(i).toCharArray();
int count = charArray.length / 8;
if (charArray.length % 8 != 0) {
count++;
}
for (int j = 1; j <= count; j++) {
int start = (j - 1) * 8;
int end = start + 7;
for (int k = start; k <= end; j++) {
if (k <= charArray.length - 1) {
System.out.print(charArray[k]);
} else {
System.out.print(0);
}
}
System.out.println();
}
}
}