i6lan 分享题目的网站
试一试站内搜索 题目类型:问答题

违反《中华人民共和国保守国家秘
某单位为了争取到投资项目,单位
关于外甥的歇后语“姥姥疼外甥”
反对民族分裂,维护祖国统一,是
在窗体中有一个名称为run35

给出下面程序输出结果。


#include <math.h>

#include <iostream.h>

#include <iomanip.h>

bool fun(long n);

void main()

{long a=10,b=30,l=0;

if(a%2==0) a++;

for(long m=a;m<=b;m+=2)

if(fun(m))

{if(l++%10==0)

cout <<endl;

cout <<setw(5) <<m;

}

}

bool fun(long n)

{int sqrtm=(int)sqrt(n);

for(int i=2;i<=sqrtm;i++)

if(n%i==0)

return false;

return true;

}


答案:11 13 17 19 23 29

[解析]循环体用来判断n是否是质数的函数,在main函数判断10~30之间质数。

上一题 下一题

CopyRight©i6lan.com 关于本站
蜀ICP备2021017061号-1

川公网安备 51010402001278号