第二关: 数据统计
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int select(int x)
{
int mark = 1;
int y = x;
int z = 0;
int t = 0;
while (y>9)
{
y /= 10;
mark *= 10;
}
do
{
if((t=x%10)!= 0)
{
if(t%8==0)
z = 1;
}
x/=10;
mark /= 10;
} while (mark!=0);
return z;
}
int main()
{
int n = 0;
int i = 0;
int m = 0;
int count = 0;
scanf("%d", &n);
for (m = 1; m <= n; m++)
{
i = select(m);//判断是否含有8
if (i != 1)
{
if (m % 15 == 0 || m % 17 == 0)
{
count++;
}
}
}
printf("满足条件的整数个数=%d", count);
return 0;
}