解题思路:桶排序

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = "";
        while ((s = br.readLine()) != null) {
            int[] counter = new int[4];
            for (char c: s.toCharArray()) {
                if (Character.isLetter(c)) {
                    counter[0]++;
                } else if (c == ' ') {
                    counter[1]++;
                } else if (Character.isDigit(c)) {
                    counter[2]++;
                } else {
                    counter[3]++;
                }
            }
            for(int n: counter) {
                System.out.println(n);
            }
        }
        br.close();
    }
}