#include <iostream>
#include <string>
using namespace std ;
int main() {
int t ;
cin >> t ;
int range ;
cin >> range ;
int counter = 0 ;
while ( t-- ) {
int j = 0 ;
string num ;
cin >> num ;
for ( char i : num ) {
int val = i - '0' ;
if ( val > range || val < 0 ) {
break ;
}
else {
j++ ;
if ( j == num.size()+1 ) {
counter++ ;
break ;
}
}
}
}
cout << counter ;
}
when the input is
10 6
1234560
1234560
1234560
1234560
1234560
1234560
1234560
1234560
1234560
1234560
I expected to find 10 in the output because each string consists of numbers from 0 to 6 range
but the output is 0
New contributor
Razan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.