HDU 2030 Kanji Statistics (Java)

Source: Internet
Author: User

Problem:

Java is more complex in judging Chinese.


Chinese character statisticsTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 29746 Accepted Submission (s): 16314


Problem description counts the number of Chinese characters in a given text file.
The input file first contains an integer n, which indicates the number of test instances, followed by the N-segment text.
Output for each piece of text, outputs the number of characters in it, and the output of each test instance takes one row.

[Hint:] From the characteristics of the Chinese character machine internal code to consider ~


Sample Input
2wahaha! wahaha! This year the festival does not speak to speak only Putonghua wahaha! Wahaha! 's going to take the final exams right now.

Sample Output
149


Code:

Import java.util.*;p ublic class main{public static void Main (String args[]) {Scanner cin=new Scanner (system.in); int n=cin . Nextint (); String S;cin.nextline (); for (int i=0;i<n;i++) {s=cin.nextline (); char[] A=s.tochararray (); int count=0;for (int j=0;j <s.length (); j + +) {Character.unicodeblock UB = Character.UnicodeBlock.of (A[j]); if (UB = = Character.UnicodeBlock.CJK _unified_ideographs| | UB = = character.unicodeblock.cjk_compatibility_ideographs| | UB = = character.unicodeblock.cjk_unified_ideographs_extension_a| | UB = = character.unicodeblock.general_punctuation| | UB = = character.unicodeblock.cjk_symbols_and_punctuation| | UB = = Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) count++;} System.out.println (count);}}}


HDU 2030 Kanji Statistics (Java)

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.