题解 | 记数问题
记数问题
https://www.nowcoder.com/practice/28b2d9f2bf2c48de94a1297ed90e1732
#include <stdio.h>
int a(int n, int m) {
int count=0;
for (int i = 1; i <= n; i++) {
int temp = i;
while (temp > 0) {
if (temp % 10 == m) {
count++;
}
temp = temp / 10;
}
}
return count;
}
int main() {
int n, m, b;
scanf("%d %d", &n, &m);
b = a(n, m);
printf("%d", b);
}