题解 | 记数问题

记数问题

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

#include <iostream>
using namespace std;

void count()
{
    int n=0,x=0,cnt=0;
    cin >> n >> x;
    for(int i=1;i<=n;i++){
    	int temp = i;
            while(temp){
                if(temp%10 == x) cnt++;
                temp /= 10;
            }
    }
    cout << cnt << endl;
}

int main() {
    count();
    return 0;
}

全部评论

相关推荐

Java转测开第一人:这种就是饼 把应届当廉价劳动力用完然后丢掉
你觉得今年秋招难吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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