The code is shown following, the string library has been commented, but the program still work well
#include<iostream>
//#include<string> // the string library has been commented
using namespace std;
int main(){
int n;
cin>>n;
for(int i=0; i<n; i++){
string str;
int num = 0;
cin>>str;
int len = str.length(); //the function length is used here!
for (int j =0; j< len; j++){
if (str[j] >='0' && str[j] <='9')
num ++;
}
cout<<num<<endl;
}
return 0;
}