题解 | 记数问题

记数问题

https://www.nowcoder.com/practice/28b2d9f2bf2c48de94a1297ed90e1732

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,num;
cin >> n >> num;
int i,count=0;
for(i=0;i<=n;i++)
{
    int term=i;
    while(term>0)
    {
        if(term%10==num)  count++;
        term/=10;
    }
}
cout << count;    
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务