import java.util.*;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for(int i = 0;i < n;i++) {
String str = sc.next();
int ans = 0;
for(int j = 0;j < str.length();j++) {
if(str.charAt(j) >= 48 && str.charAt(j) <= 57) { //0~9转换为ASCII码为48~57
ans++;
}
}
System.out.println(ans);
}
}
}
sc.next()和sc.nextLine()的区别
相同点:都是用来接受用户的输入字符串
区别:
next()从遇到第一个有效字符(非空格、换行符)开始扫描,遇到第一个分隔符或结束符(空格’ ‘或者换行符 ‘\n’)时结束
nextLine()则是扫描剩下的所有字符串直到遇到回车为止。