1、计算字符串的长度是否是8的倍数,如果不是8的倍数(取余),后面需要补充N个0,使长度正好凑够8的倍数
2、然后遍历截取字符串,8个字符一组
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
while(sc.hasNext()){
StringBuffer sb=new StringBuffer();
sb.append(sc.nextLine());
int length=sb.length();
if(length%8 !=0){
int addZero=8-length%8;
for(int i=0;i<addZero;i++){
sb.append("0");
}
}
String str=sb.toString();
for(int i=0;i<str.length()/8;i++){
System.out.println(str.substring(i*8,i*8+8));
}
}
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
while(sc.hasNext()){
StringBuffer sb=new StringBuffer();
sb.append(sc.nextLine());
int length=sb.length();
if(length%8 !=0){
int addZero=8-length%8;
for(int i=0;i<addZero;i++){
sb.append("0");
}
}
String str=sb.toString();
for(int i=0;i<str.length()/8;i++){
System.out.println(str.substring(i*8,i*8+8));
}
}
}
}
}