展开全部
Private Sub Command1_Click()
Dim i As Integer, j As Integer, x As Integer
For i = 3 To 100
x = 0 'i是素数的标记
For j = 2 To i - 1 '如在此范围内都不能整除,i就是素数
If i Mod j = 0 Then x = 1 '如整除了,就不是素数
Next j
If x = 0 Then
k = k + 1
Print Tab(5 * k); i; '如是素数,就输出i
If k = 5 Then Print: k = 0
End If
Next i
End Sub
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
dim i as integer, j as integer, ss as Boolean, n as integer
dim sp as string
sp=0: n=1
for i=3 to 100
ss=true
for j=20 to i-1
if i mod j = 0 then
ss=false
exit for
end if
next
if ss then
if n=5 then
n=1
ss=ss & vbcrlf
endif
ss=ss & i
end if
next
print ss
msgbox "OK"
dim sp as string
sp=0: n=1
for i=3 to 100
ss=true
for j=20 to i-1
if i mod j = 0 then
ss=false
exit for
end if
next
if ss then
if n=5 then
n=1
ss=ss & vbcrlf
endif
ss=ss & i
end if
next
print ss
msgbox "OK"
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询