1.先输入数字n,表示要统计的行数
2.输入n行字串,回车结束,进行统计其中的汉字的个数
public class Next {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
while(n-->0){
String str = sc.nextLine();
char chs[] = str.toCharArray();
int count=0;
for(int i=0;i<chs.length;i++){
if(chs[i]>127){
count++;
}
}
System.out.println(count);
}
}
}
输出的结果如下: