"Huawei OJ" "056-count capital letters"

Source: Internet
Author: User

"Huawei OJ" "Algorithm Total chapter" "Huawei OJ" "056-Count Capital letters" "Project Download" topic description
找出给定字符串中大写字符(即‘A‘-‘Z‘)的个数接口说明    原型:int calcCapital(String str);    返回值:int
Enter a description
输入一个String数据
Output description
输出string中大写字母的个数
Input example
add123#$%#%#O
Output example
1
Algorithm implementation
ImportJava.util.Scanner;/** * Author: Wang Junshu * date:2015-12-25 15:16 * All rights Reserved!!! */ Public  class Main {     Public Static void Main(string[] args) {Scanner Scanner =NewScanner (system.in);//Scanner Scanner = new Scanner (Main.class.getClassLoader (). getResourceAsStream ("Data.txt"));         while(Scanner.hasnext ())            {String input = Scanner.nextline ();        SYSTEM.OUT.PRINTLN (count (input));    } scanner.close (); }Private Static int Count(String s) {intresult =0; for(inti =0; I < s.length (); i++) {Charc = S.charat (i);if(c >=' A '&& C <=' Z ') {result++; }        }returnResult }}

"Huawei OJ" "056-count capital letters"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.