题解 | #字符串最后一个单词的长度#
字符串分隔
http://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
用处了菜鸡才会想到的办法,不知道各位能给多少分 不过通俗易懂才是最好的算法吧,哈哈,所以给100吧 嘻嘻 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); } }