import java.util.Scanner; public class Main { /** * 统计出英文字母字符的个数。 */ public int getEnglishCharCount(String str) { int count = 0; for (char ch : str.toCharArray()) { if (ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z') { count++; } } return count; } /** * 统计出空格字符的个数。 */ public int getBlankCharCount(String str) { int count = 0; for (char ch : str.toCharArray()) { if (ch == ' ') count++; } return count; } /** * 统计出数字字符的个数。 */ public int getNumberCharCount(String str) { int count = 0; for (char ch : str.toCharArray()) { if (ch >= '0' && ch <= '9') count++; } return count; } /** * 统计出其它字符的个数。 */ public int getOtherCharCount(String str) { int count = 0; for (char ch : str.toCharArray()) { if (ch == ' ' || ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' || ch >= '0' && ch <= '9') continue; count++; } return count; } public Main() { Scanner in = new Scanner(System.in); while (in.hasNextLine()) { String string = in.nextLine(); System.out.println(getEnglishCharCount(string)); System.out.println(getBlankCharCount(string)); System.out.println(getNumberCharCount(string)); System.out.println(getOtherCharCount(string)); } } public static void main(String[] args) { Main solution = new Main(); } }