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.
#include <stdio.h>
#include <string.h>
int main ()
{
Char a[1000];
int n,i,s;
scanf ("%d", &n);
while (n--)
{
Gets (a);
s=0;
For (I=0;i<strlen (a); i++)
{
if (a[i]<0)//The ASCII of Chinese characters is less than 0!!!
s++;
}
printf ("%d\n", S/2);/Kanji takes two bytes, so divide by 2!!!
}
return 0;
}
How to view the number of Chinese characters calculation method Hangzhou Electric 2030