作业帮 > 综合 > 作业

VB利用随机函数产生30个[3,99]整数,打印输出其中的素数(要求用数组存放)

来源:学生作业帮 编辑:百度作业网作业帮 分类:综合作业 时间:2024/04/28 20:02:16
VB利用随机函数产生30个[3,99]整数,打印输出其中的素数(要求用数组存放)
VB利用随机函数产生30个[3,99]整数,打印输出其中的素数(要求用数组存放)
dim a(30)
for i = 1 to 30
a(i)=int(rnd(97+3))
if isprime(a(i))=true then print a(i);
next i
function isprime(x as integer) as boolean
for i= 2 to x-1
if x mod i = 0 then exit for
next i
if i>x-1 then
isprime=true
else
isprime=false
end if
end function