import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        int letter = 0;
        int digit = 0;
        int other = 0;
        for(int i = 0; i < str.length() - 1; i++){
            char a = str.charAt(i);
            if((a >= 'a' && a <= 'z') || (a >= 'A' && a <= 'Z')){
                letter++;
            }else if(a >= '0' && a <= '9'){
                digit++;
            }else{
                other++;
            }
        }
        System.out.printf("Letters=%d\nDigits=%d\nOthers=%d\n",letter, digit, other);
    } 
}
我是用选择语句来读取字符,把字符的每个元素都来出来进行比较,除了最后一个,然后计算结果,最后打印结果。