zoukankan      html  css  js  c++  java
  • 华为OJ平台——统计字符串中的大写字母

    题目描述:

      统计字符串中的大写字母的个数

    输入:

      一行字符串

    输出:

      字符串中大写字母的个数(当空串时输出0)

    思路:

      这一题很简单,直接判断字符串中的每一个字符即可,唯一要注意的一点是输入的字符串可能包含空格,所以读入的时候要用nextLine()方法

     1 import java.util.Scanner;
     2 
     3 public class CountCaptial {
     4 
     5     public static void main(String[] args) {
     6         Scanner cin = new Scanner(System.in) ;
     7         String str = cin.nextLine() ;
     8         cin.close() ;
     9         
    10         int count = 0 ;
    11         char temp ;
    12         for(int i = 0 ; i < str.length() ; i++){
    13             temp = str.charAt(i) ;
    14             if((temp <= 'Z') && ( temp >= 'A')){
    15                 count++ ;
    16             }
    17         }
    18         
    19         System.out.println(count);
    20 
    21     }
    22 
    23 }
  • 相关阅读:
    FirstThunk
    FirstThunk
    输入地址表(IAT)
    PE文件讲解
    PE格式详细讲解
    pe结构讲解
    PE格式详细讲解
    输入地址表(IAT)
    pe结构讲解
    zindex可以使用负值
  • 原文地址:https://www.cnblogs.com/mukekeheart/p/5635461.html
Copyright © 2011-2022 走看看