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 input2wahaha! wahaha! This year the festival does not speak to speak only Putonghua wahaha! Wahaha! 's going to take the final exams right now.
Sample Output149
Authorlcy
Source C language Programming exercises (v)
Recommendlcy | We have carefully selected several similar problems for you:2031 2032 2026 2027 20,241 kanji accounted for two bytes, which is two char, and the ACSII code is negative. Code:
#include <iostream>#include<cstdio>#include<algorithm>#include<cstring>#defineINF 0x3f3f3f3f#defineMAX 100000using namespacestd;intN;Chars[10000];intMain () {scanf ("%d\n",&N); while(N--) {gets (s); intAns =0; for(inti =0; S[i];i + +) { if(S[i] <0) ans + +; } printf ("%d\n", ans/2); }}
HDU 2030 Kanji Statistics