华为机试题四

#include <iostream>
using namespace std;
int fun1(int m)
{
  int temp;
  while (m)
  {
	  temp = m%10;
      if(temp == 7)  return 1;
	  m = m/10; 
  }
  return 0;
}
/*
int fun2(int m)
{
  int temp=m%10;
  while(temp)
  {
      if(temp == 7)  return 1;
	  m = m/10; 
	  temp = m%10;
  }
  return 0;
}
*/
int main()
{
	
   int a,i;
   int num =0;
   cin>>a;
   for (i=1;i<=a;i++)
   {
	    if( i%7==0 || fun(i) == 1)
		   num++;
   }
   cout<<num<<endl;
   
}

 挑7

原文地址:https://www.cnblogs.com/zlj830/p/4717143.html