题解 | #挑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;
}

全部评论

相关推荐

程序员花海_:实习和校招简历正确格式应该是教育背景+实习+项目经历+个人评价 其中项目经历注意要体现业务 实习经历里面的业务更是要自圆其说 简历模板尽可能保持干净整洁 不要太花哨的
点赞 评论 收藏
分享
11-06 16:50
门头沟学院 Java
用微笑面对困难:word打字比赛二等奖的我,也要来凑合凑合
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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