题解 | 牛牛数数

牛牛数数

https://www.nowcoder.com/practice/03a3cc96fa4847b387bf58bb800d67cf

#include <bits/stdc++.h>
using namespace std;
bool foo(int a){
    if(a%4==0){
        return false;
    }
    while(a>0){
        if(a%10==4){
           return false;
        }
        a = a/10;
    }
    return true;
}
int main(){
    int n;
    cin >>n;
    int a[n];
    for (int i = 1;i<=n;i++){
        if(foo(i)){
            cout << i <<endl;
        }
    }
    return 0;
}
妈呀,终于弄出来了

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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