汉字统计:
#include<iostream>
#include<string.h>
using namespace std;
#define N 1000
char str[N];
int main(){
int n;
int len;
int i;
int count;
cin>>n;
cin.ignore();
while(n--){
memset(str,'0',N*sizeof(char));
gets(str);
count=0;
len=strlen(str);
for(i=0;i<len;++i)
if(str[i]<0)
count++;
cout<<count/2<<endl;
}
return 0;
}
转载于:https://blog.51cto.com/beyond316/1256086