原题:

 

Problem Description
  统计给定文本文件中汉字的个数。

 

 

Input
  输入文件首先包含一个整数n,表示测试实例的个数,然后是n段文本。

 

 

Output
  对于每一段文本,输出其中的汉字的个数,每个测试实例的输出占一行。

[Hint:]从汉字机内码的特点考虑~

 

 

Sample Input
  2
WaHaHa! WaHaHa! 今年过节不说话要说只说普通话WaHaHa! WaHaHa!
马上就要期末考试了Are you ready?

 

 

Sample Output
  14
9

 

分析:

水题:不解释;——————一个汉字占2个机内码(我也不知道神马叫机内码~理解成字节类似的东东就行,神州行、我看行!)

原码:

#include <stdio.h> #include <string.h> int main() {     int n;     int count;     char c;      scanf("%d%c", &n);      while (n--)     {         count = 0;          while ((c = getchar()) != '\n')         {             if (c < 0)                 count++;         }          printf("%d\n", count / 2);     }      return 0; }