- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- String line = sc.nextLine();
-
- int eng = 0;
- int space = 0;
- int num = 0;
- int other = 0;
-
- char[] arr = line.toCharArray();
- for (char c : arr) {
- if(((c >= 'a' )&& (c <= 'z')) ||( c >= 'A' && c <= 'Z')){
- eng++;
- }else if(c == ' '){
- space++;
- }else if(c >= '0' && c <= '9'){
- num++;
- }else {
- other++;
- }
- }
- System.out.println(eng + "====" + space + "====" + num + "===" + other);
- }
- }
复制代码
|
|