vb语言吧 关注:102贴子:143
  • 0回复贴,共1

判断素数 提示 next 没有 for 怎么改啊啊啊

取消只看楼主收藏回复

Private Sub Command1_Click()
Dim n As Integer, i As Integer
n = Val(Text1.Text)
For i = 2 To n - 1
If n Mod i = 0 and i<=n-1Then
MsgBox (n & "不是素数")
Exit For
Next i
End If
If i > n - 1 Then
MsgBox (n & "是素数")
End If
End Sub


IP属地:广东1楼2015-12-08 20:26回复