题解 | #统计字符#

统计字符

https://www.nowcoder.com/practice/539054b4c33b4776bc350155f7abd8f5

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        System.out.println(str.replaceAll("[^A-Za-z]","").length());
        System.out.println(str.replaceAll("[^\\s]","").length());
        System.out.println(str.replaceAll("[^0-9]","").length());
        System.out.print(str.replaceAll("[\\s]|[0-9]|[A-Za-z]","").length());
    }
}

全部评论

相关推荐

02-04 12:01
九江学院 C++
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务