题解 | #挑7#
挑7
http://www.nowcoder.com/practice/ba241b85371c409ea01ac0aa1a8d957b
#include<stdio.h>
int Contain7(int x)
{
if(x == 0)
return 0;
if(x%10 == 7)
return 1;
return Contain7(x/10);
}
int main()
{
int n;
int cnt = 0;
int i = 0;
while(scanf("%d",&n)!=EOF)
{
for(i=7;i<=n;i++)
{
if(i%7==0)
{
cnt++;
}
else if(Contain7(i))
{
cnt++;
}
}
printf("%d",cnt);
}
return 0;
}