fork download
  1. import java.util.Scanner;
  2. public class Main{
  3. public static void main(String[] args){
  4. Scanner sc=new Scanner(System.in);
  5. String str=sc.next();
  6. System.out.println("数字个数"+CountInt(str)+"大写字母个数"+CountBig(str)+"小写字母个数"+CountSmall(str));
  7.  
  8. }
  9. public static int CountInt(String str){
  10. int count=0;
  11. for(int i=0;i<str.length();i++){
  12. char c=str.charAt(i);
  13. if(c >=48&&c<=57){
  14. count++;
  15. }
  16. }
  17. return count;
  18. }
  19. public static int CountBig(String str){
  20. int count=0;
  21. for(int i=0;i<str.length();i++){
  22. char c=str.charAt(i);
  23. if(c >=65&&c<=90){
  24. count++;
  25. }
  26. }
  27. return count;
  28. }
  29. public static int CountSmall(String str){
  30. int count=0;
  31. for(int i=0;i<str.length();i++){
  32. char c=str.charAt(i);
  33. if(c >=97&&c<=122){
  34. count++;
  35. }
  36. }
  37. return count;
  38. }
  39. }
Success #stdin #stdout 0.28s 58904KB
stdin
aaa1234ABC
stdout
数字个数4大写字母个数3小写字母个数3