杭州电子科技大学(HDU)ACM刷题----------汉字统计

#include 
using namespace std;
int main()
{
	int n;
	cin>>n;
	getchar();           //用getchar()吃掉回车符
	while (n--)
	{
		int flag=0,sum=0;
		char str[50];
		gets(str);
		for (int i=0;str[i]!='\0';i++){
			sum++;
			if (str[i]>=0&&str[i]<=127)
			{
				flag++;
			}
		}
		cout<<(sum-flag)/2<

你可能感兴趣的:(算法与数据结构,数据结构与算法)