题解 | #挑7#

挑7

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

#include <stdio.h>
#include <string.h>

int main(){

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

    int count = 0;
    for(int i = 1, k = 0; i <= n; i++){
        if(i % 7 == 0){
            count++;
            continue;;
        }
        int tmp;
        k = i;
        while(k != 0){
            tmp = k % 10;
            if(tmp == 7){
                count++;
                break;
            }
            k = k / 10;
        }
    }

    printf("%d", count);


    return 0;
}

全部评论
逢七过!
点赞 回复 分享
发布于 2023-03-13 12:21 美国

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务