文章

94

粉丝

0

获赞

19

访问

2.8k

头像
数字统计 题解:
P1002 兰州大学机试题
发布于2026年1月24日 10:56
阅读数 22

#include<stdio.h>
#include<string.h>
int fun(int x)
{
    int s=0;
    while(x!=0)
    {
        int k=x%10;
        if(k==2)
        {
            s+=1;
        }
        x=x/10;
    }
    return s;
}
int main()
{
    int l,r;
    while(scanf("%d %d",&l,&r)!=EOF)
    {
        int count=0;
        for(int i=l;i<=r;i++)
        {
            count+=fun(i);    
        }
        printf("%d\n",count);
...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发