HDU 2030 汉字统计

 1 #include<stdio.h>
 2 #include<stdlib.h>
 3 char str[1100];
 4 int calc(char str[])
 5 {
 6     int i,sum=0;
 7     for(i=0;str[i];i++)
 8     if(str[i]&0x80)  
 9     {sum++;i++;}//这里i++是由于汉字占两个字节, 
10     return sum;
11 }
12 int main()
13 {
14     int n;
15     scanf("%d%*c",&n);
16     while(n--)
17     {
18         gets(str);
19         printf("%d\n",calc(str));
20     }
21     system("pause");
22     return 0;
23 }    
24     
25      

posted on 2012-08-02 16:19  mycapple  阅读(205)  评论(0)    收藏  举报

导航