#include <iostream>
using namespace std;
bool check1(int x)
{
    if(x%7==0) return true;
    else return false;
}

bool check2(int x)
{
    int g=0;
    while(x>0)
    {
        g=x%10;
        if(g==7) return true;
        x/=10;
    }
    return false;
}

int main() 
{
    int n;
    cin>>n;
  //jingen
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(check1(i)) cnt++;
        else
         {
            if(check2(i)) cnt++;
         };
    }
    cout<<cnt;
  return  0;
}

由题意,再循环里用两个函数判断是否是7的倍数,或者是否各位数字是否包含7,cnt进行计数,输出即可参与链接