#include <stdio.h>
#include <math.h>
int main(int argc, const char *argv[])
{
int i,t;
for (i=2;i<1000;i++){
t=1;
for (int j=2;j<=sqrt(i);j++){
if (i%j==0)
{
t=0;
break;
}
}
if (t)
{
printf("%d ",i);
}
}
int x=1,y;
for (int i=1;i<10;i++){
y=(x+1)*2;
x=y;
}
printf("\n猴子共摘了%d个桃\n",y);
#include <stdio.h>
#include <math.h>
int main(int argc, const char *argv[])
{
float a,b;
for (float i=1;i<9999;i++)
{
a=sqrt(i+100);
b=sqrt(i+100+168);
if (a==(int)a&&b==(int)b )
printf("%f\n",i);
}
return 0;
}


文章包含两个C语言程序片段,一个是使用循环和条件判断检测1到999之间的质数,另一个是计算并输出1到9999之间满足特定整数平方根条件的浮点数。
1333

被折叠的 条评论
为什么被折叠?



