关键要知道汉字是占两个字符的,且每个字符的值都<0;直接用字符就可以做的。但要记得输入字符前加个getchar();
代码:
#include"iostream"
#include"string"
using namespace std;
int main()
{
int n;
char c;
cin>>n;
getchar();
while(n--)
{
int s=0;
while((c=getchar())!='\n')
{
if(c<0)
s++;
}
cout<<s/2<<endl;
}
return 0;
}