题解 | #字符串最后一个单词的长度#
// 用处了菜鸡才会想到的方法,不知道各位能给多少分 import java.util.Scanner;
public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); String str = sc.nextLine(); int len = str.length(); int carry = len / 8; int last = len % 8; for(int i = 0;i < carry * 8;i=i+8){ String target = str.substring(i,i+8); System.out.println(target); } String lst = str.substring(carry * 8); while(last < 8 && last > 0){ lst += "0"; last++; } System.out.println(lst); } }