解题
最后一词
http://www.nowcoder.com/questionTerminal/9eeeb5d680094dfca66251b958ecdcce
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String string = scanner.nextLine();
    test01(string);
}
public static int test01(String name){
    int length = name.length()-1;
    int count=0;
    for (int i = length; i >= 0; i--) {
        if(name.charAt(i)!=' '){
            count++;
        }
        if(name.charAt(i)==' '){
            break ;
        }
    }
    System.out.println(count);
    return count;
}}
查看6道真题和解析
