题解 | #[NOIP2010]数字统计#
[NOIP2010]数字统计
https://www.nowcoder.com/practice/179d9754eeaf48a1b9a49dc1d438525a
//BC153[NOIP2010]数字统计
#include<stdio.h>
int Fun(int L1, int L2)
{
int n = 0;
int count = 0;
for (int i = L1; i <= L2; i++)
{
n = i;
while (n)
{
if (n % 10 == 2)
{
count++;
}
n /= 10;
}
}
return count;
}
int main()
{
int L = 0;
int R = 0;
scanf("%d %d", &L, &R);
int ret = Fun(L, R);
printf("%d\n", ret);
return 0;
}

