解题思路:用for输出n以内的数,再拿每一个对7求余,符合条件则记一次。再用while循环统计不能用7整除,但是含有7的数
注意事项:用while循环时,符号条件的记得跳出,不然一个数会记好几次;
参考代码:
#include<stdio.h>
int main()
{
int i;
int N;
int count=0;
int temp;
scanf("%d",&N);
for(i=1; i<=N; i++)
{
temp =i;
if(i%7==0)
{
count++;
}
else
{
while(temp)
{
if(temp%10==7)
{
count++;
break;
}
temp/=10;
}
}
}
printf("%d",count);
}
0.0分
0 人评分
输出九九乘法表 (C语言代码)浏览:555 |
十->二进制转换 (C语言代码)浏览:1291 |
兰顿蚂蚁 (C++代码)浏览:1044 |
C语言程序设计教程(第三版)课后习题6.11 (C语言代码)浏览:2080 |
printf基础练习2 (C语言代码)浏览:746 |
1157题解浏览:711 |
A+B for Input-Output Practice (IV) (C语言代码)浏览:484 |
C二级辅导-统计字符 (C语言代码)浏览:476 |
分糖果 (C语言代码)浏览:912 |
简单的a+b (C语言代码)浏览:818 |