import java.util.Scanner;  //抄别人的
public class Main{
    public static void main(String[] age){
    		Scanner in=new Scanner(System.in);
    		int word = 0, number = 0, space = 0, others = 0;
    		String ch=in.nextLine();
    	    for(int i=0;i<ch.length();i++){
    	    	char c=ch.charAt(i);//依次取出每个字母  
    	    	   if ('a' <= c && c <= 'z' || 'A' <= c && c <= 'Z') {
    	               word++;
    	           } else if ('0' <= c && c <= '9') {
    	               number++;
    	           } else if (c == ' ') {
    	               space++;
    	           } else {
    	               others++;
    	           }
    	    }System.out.println(word+" "+number+" "+space+" "+others);
    	}

    }
 

0.0分

1 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答

代码解释器

  评论区

理解的很透彻
2019-12-16 22:22:12
是不是可以用正则,直接返回符合的数量。
2019-11-29 16:32:09
  • «
  • 1
  • »