标签:
要点:一个汉字占两个字节,且这两个字节对应的整数值为负,即符号位是1
1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 using namespace std; 5 6 const int N = 10001; 7 char str[N]; 8 9 int main () 10 { 11 int t; 12 cin >> t; 13 getchar(); 14 while ( t-- ) 15 { 16 cin.getline( str, N - 1 ); 17 int len = strlen(str), cnt = 0; 18 for ( int i = 0; i < len; i++ ) 19 { 20 if ( str[i] < 0 ) cnt++; 21 } 22 cout << cnt / 2 << endl; 23 } 24 return 0; 25 }
标签:
原文地址:http://www.cnblogs.com/huoxiayu/p/4474457.html