求1000~1100之间的所有素数
发布网友
发布时间:2024-10-24 19:06
我来回答
共3个回答
热心网友
时间:2024-10-24 22:17
'添加一个按钮 CommandButton 控件,双击它,在它的单击事件中,写入以下代码。
Private Sub Command1_Click()
Dim i As Integer, j As Integer, ss As Boolean
For i = 1000 To 1100
ss = True
For j = 2 To Int(Sqr(i))
If i Mod j = 0 Then ss = False: Exit For
Next
If ss = True Then Me.Print i
Next
End Sub
热心网友
时间:2024-10-24 22:18
楼上的麻烦了吧
添加控件相同
private sub Command1_click()
dim i,j
For i = 1000 to 1100
for j = 2 to Int(Sqr(i))
if i Mod j = 0 then
print i : Exit For
end if
next j
next i
end sub
热心网友
时间:2024-10-24 22:18
二楼的答案不对吧,这样输出的就是合数。一楼是对的,顶一下。