import java.util.Scanner;public class Main{ public static void main(String [] args){ Scanner canner=new Scanner(System.in); while(canner.hasNextLine()){ String str=new StringBuffer(canner.nextLine()).toString(); int result= str.substring(str.lastIndexOf(" ")+1,str.length()).length(); System.out.println(result); } }} 我已经通过这道算法题! https://www.nowcoder.com/questionTerminal/8c949ea5f36f422594b306a2300315da