题解 | #包含数字9的数#

包含数字9的数

https://www.nowcoder.com/practice/0948f4f3344c452f843afd3585dd0f8d

#include <iostream>
using namespace std;

int main() {
    int count=0;
    for (int a = 1; a <= 2019; a++) {
        int b=a;
        while (b > 0) {
            if (b % 10 == 9) {count++;break;}
            else b = b / 10;
        }
    }
    cout<<count;
    return 0;
}

全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

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