参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); statistic(scanner.nextLine()); } public static void statistic(String x) { int e, n, s, o; e = n = s = o = 0; for(char t: x.toCharArray()) if(t >= 'a' && t <= 'z' || t >= 'A' && t <= 'Z') e++; else if(t >= '0' && t <= '9') n++; else if(t == ' ') s++; else o++; System.out.print(e + " " + n + " " + s + " " + o); } }
0.0分
5 人评分