用C语言for循环编写程序“打印100-200之间的所有素数(按照每行5个显示)”求解

如题所述

第1个回答  2013-11-22
#include <math.h>
#include <stdio.h>int isPrime(int i)
{
int x;
int y = (int)ceil(sqrt(i)); if (i%2==0 || i<2)
return 0; for (x=3; x<=y; x++)
if (i%x == 0)
return 0; return 1;
}int main(void)
{
int c = 0, i; for (i=100; i<=200; i++)
if (isPrime(i))
{
printf("%4d", i);
c++; if (c == 5)
{
printf("\n");
c = 0;
}
} return 0;
}本回答被网友采纳
第2个回答  2013-11-22
可以找哥啊 我学软件的
第3个回答  2013-11-22
这个嘛,不会,我们学的是Java