题解 | #挑7#

挑7

https://www.nowcoder.com/practice/ba241b85371c409ea01ac0aa1a8d957b

#include <stdio.h>

int main() {
    int a;
    int cnt = 0;
    scanf("%d",&a);
    for (int i=1; i<=a; i++) {
        int temp = i;
        if(temp%7 == 0) cnt++;
        else if (temp % 10 ==7){
            cnt++;
        }else if ((temp/10)%10 ==7&& temp >=10) {
            cnt++;
        }else if ((temp/100)%10 ==7&& temp >=100) {
            cnt++;
        }else if ((temp/1000)%10 ==7&& temp >=1000) {
            cnt++;
        }else if ((temp/1000)%10 ==7&& temp >=10000) {
            cnt++;
        } 
    }
    printf("%d",cnt);
    return 0;
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
今天 15:58
点赞 评论 收藏
分享
06-10 21:15
门头沟学院 Java
宁阿:好多这种没🧠的公司,他们估计都不知道毕业的人不能给安排实习岗
实习吐槽大会
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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