1. 截取最后一个单词
  2. 计算长度
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String input = sc.nextLine();
            String lastWorld = input.substring(input.lastIndexOf(" ") + 1);
            System.out.println(lastWorld.length());
        }
    }
}

(为什么这么简单的题目,难度是较难?)