题解 | #统计大写字母个数#

统计大写字母个数

https://www.nowcoder.com/practice/434414efe5ea48e5b06ebf2b35434a9c

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()){
            String in = sc.nextLine();
            String up = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            int count = 0;
            for (int i = 0; i < in.length(); i++) {
                if (up.contains(in.substring(i,i+1))){
                    count++;
                }
            }
            System.out.println(count);
        }
    }
}

全部评论

相关推荐

03-10 11:23
门头沟学院 Java
鹿LF:计算机面试就跟数学题一样,没什么实际价值,但只能这么筛选,本质是考察你的努力,智力和学习能力
点赞 评论 收藏
分享
04-13 09:56
已编辑
嵌入式工程师
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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