高轨低速大周期大机大势大能量
2021-01-24 23:32c语言 输出1~n之间的所有素数,每5个换行。请问for循环的表达式有什么问题吗?
#include<stdio.h>
#include<math.h>
int main()
{
int i,n,j,count=0;
scanf("%d",&n);
for(i=n-1;i>1;i--)
{
for(j=i;j>=(int)sqrt(i*1.0);j--)
{
if(i%j==0) break;
else
if(j<(int)sqrt(i*1.0))
count++;
printf("%d\t",i);
if(count%5==0) printf("\n");
}
}
return 0;
}
- 点赞
- 回答
- 收藏
- 复制链接分享
2条回答
为你推荐
- 这个程序我写了蛮久但一直得不到答案,也不知道问题出在哪,各位大神可以帮帮我吗?
- c语言
- 1个回答
- 只使用while输出100以内质数 怎么做?Python
- php
- 1个回答
- 关于for循环的条件——C语言求素数??
- c语言
- 1个回答
- 求大佬帮忙看一下我用C语言写的编程题代码有什么问题
- c语言
- 2个回答
- 2019第一个问题,请问用C语言怎么实现素数的这个算法?
- r语言
- Golang
- erlang
- 2个回答
换一换