help !!!! to understand this code! | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
- 3

help !!!! to understand this code!

Given an integer X within the range of 0 to 9, and given two positive integers as upper and lower bounds respectively, find the number of times X occurs as a digit in an integer within the range, excluding the bounds. Print the frequency of occurrence as output. using namespace std; int main() { int t; cin>>t; while(t--) {int l,u,x; cin>>x; cin>>l>>u; int c=0; for(int i=l+1;i<u;i++) {int num=i; while(num!=0) { if(num%10==x) {c++;} num=num/10;}} cout<<c<<endl; } return 0; }

6th Sep 2018, 5:39 AM
White code
White code - avatar
0 Antworten