首页 > 其他 > 详细

判断字符是否为大写字母

时间:2020-07-14 15:58:26      阅读:164      评论:0      收藏:0      [点我收藏+]

技术分享图片

 

 

/*
    先把字符串转为字符数组,遍历字符数组,若ASCII码在65-90之间,则count+1
*/
import java.util.*;
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            String str = sc.nextLine();
            int count = 0;
            char ss[] = str.toCharArray();
            for (int i = 0; i < ss.length; i++){
                if(ss[i]>=‘A‘ && ss[i]<=‘Z‘){
                    count++;
                }
            }
            System.out.println(count);
        }
    }
}

 

判断字符是否为大写字母

原文:https://www.cnblogs.com/gy7777777/p/13299215.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!