解题思路:
注意事项:
参考代码:
import java.util.*;
public class A1012 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
int a = 0;
int b = 0;
int c = 0;
int d = 0;
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z' || s.charAt(i) >= 'A'
&& s.charAt(i) <= 'Z')
a++;
else if (s.charAt(i) >= '0' && s.charAt(i) <= '9')
b++;
else if (s.charAt(i) == ' ')
c++;
else {
d++;
}
}
System.out.print(a + " " + b + " " + c + " " + d);
}
}
0.0分
3 人评分