Title Description
Calculate the range of 11 1 to nn all integer n, the numbers the X-(0≤x≤9) the X-(0 ≤ ≤ the X-9) the X- ( 0 ≤ the X- ≤ 9 ) there was a total of how many times? For example, in . 11 1 to . 11. 11 1 1, i.e. 1,2,3,4,5,6,7,8,9,10,111,2,3,4,5,6,7,8,9, 10, 11 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 1 0 , 1 1, numeral . 11 1 appeared 44 is four.
Input Format
22 is two integers n-, Xn, X n- , X, separated by a space between.
Output Format
11 an integer representing the xx number of times x appears.
Sample input and output
Input # 1
11 1
Output # 1
4
Code
#include <stdio.h>
int main () {
int A, B, J = 0;
Scanf ( "% D% D", & A, & B);
for (int I =. 1; I <= A; I ++ ) {
int D = I;
the while (D> 0) {
int C D% = 10; // get the last bit of
d = d / 10; // remove the last
IF (C == B) {
J ++; / / is determined whether the same, then the cycle has to know the number 0 ==
}
}
}
the printf ( "% D", J);
return 0;
}