题解 | 记数问题

记数问题

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

#include <stdio.h>

int main() {
    int n, x, temp;
    int i_cnt, x_total_cnt, i;

    scanf("%d %d", &n, &x);

    x_total_cnt = 0;
    for(i = 1; i <= n; i++) {
        i_cnt = 0;
        temp = i;
        while(temp) {
            if(temp % 10 == x) {
                i_cnt++;
            }
            temp = temp / 10;
        }
        x_total_cnt += i_cnt;
    }
        // 64 位输出请用 printf("%lld") to 
    
    printf("%d\n", x_total_cnt);
    
    return 0;
}

全部评论

相关推荐

08-18 15:52
Python
码农索隆:这孩子真实诚,说周一有急事啊
点赞 评论 收藏
分享
DKS233:项目写太简单了,你用什么技术实现了什么功能,优化了多少,分了哪些模块,解决了哪些难点,最好分模块写,你写的太模糊了。精通还是少用吧,你确定问你底层你扛的住吗,最好用熟悉。具备良好**意识,这种空话不要写,技能层面,要写就写实在的,比如“熟悉常用数据结构,如,堆,栈,链表,哈希表,平衡树”这种
你的简历改到第几版了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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