标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 36782 Accepted Submission(s):
20003
import java.util.*;
class Main{
public static void main(String args[])
{Scanner cin=new Scanner(System.in);
int n=cin.nextInt();
cin.nextLine();
while(n-->0)
{String str=cin.nextLine();
byte []s=str.getBytes();
int sum=0;
for(int i=0;i<s.length;i++)
{if(s[i]<0)
sum++;}
System.out.println(sum/2);
}
}
}
汉字的机内码是个负数,但汉字的机内码占两个字节,所以统计汉字的时候要除以2;
标签:
原文地址:http://www.cnblogs.com/1314wamm/p/5372424.html