HDU 2027 Kanji Statistics

Source: Internet
Author: User

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


problem Descriptioncounts the number of Chinese characters in a given text file.  
InputThe input file first contains an integer n, which indicates the number of test instances, followed by the N-segment text.  
Outputfor each piece of text, output the number of Chinese characters, and one row for each test instance.

[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
 
AuthorLCY 
SourceC language Programming exercises (v)Ideas:

because the ASCII code of the Chinese characters are negative, and each Chinese character accounted for two bytes, it will be counted less than 0 of the number divided by 2 to get the desired result!

Code:
/* *************************************************************************** * * * *  file name: HDU2027201507231707 * * Created by: New * * Date  : July 23, 2015 17:07:25 * * Function Description: Statistics of the number of characters in a given text * * Version  : Dev C + +  * Modified by: NEW * * * * * * * * * * * * * * * * * *   */  #include <stdio.h># Include <string.h>int main () {char a[1000];int n,i,j,k,t;scanf ("%d", &n), GetChar (); while (n--) {gets (a); t= Strlen (a); for (i=0,j=0;i<t;i++) {if (a[i]<0)   


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

HDU 2027 Kanji Statistics

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.