题解 | #[NOIP2013]记数问题#
[NOIP2013]记数问题
https://www.nowcoder.com/practice/28b2d9f2bf2c48de94a1297ed90e1732
#include <stdio.h>
int main()
{
int n, x;
int count = 0;
scanf("%d %d", &n, &x);
for (int i = 1; i <= n; i++)//每一次循环判断一个数,直到n为止
{
int a = i;
while (a)//利用while循环判断每一位数字,直到a等于0,
{
if (a % 10 == x)//如果个位上的数字是x,count加一
count++;
a /= 10;//将个位上的数字去除,十位上的数字变成个位上的数字
}
}
printf("%d", count);
return 0;
}

