题解 | #[NOIP2010]数字统计#
[NOIP2010]数字统计
https://www.nowcoder.com/practice/179d9754eeaf48a1b9a49dc1d438525a
#include <stdio.h>
int main()
{
int test(int a,int b);
int a, b;
scanf("%d %d",&a,&b);
int z=test(a,b);
printf("%d",z);
return 0;
}
int test(int a,int b)
{
int c=0;
int i;
for(i=a;i<=b;i++)
{
int sam;
int temp=i;
while (temp>0)
{
sam=temp%10;
if(sam==2)
{
c++;
}
temp/=10;
}
}
return c;
}
#牛客创作赏金赛#
查看29道真题和解析