vb编写一个程序,利用随机函数Rnd生成10个10-99之间的整数,并计算其中素数的个数

Private Sub Command1_Click()
Dim i As Integer, j As Integer, n As Integer, n1 As Integer, st As String
For i = 1 To 10
n =_
st = _
For j = 2 To _
If n Mod j = 0 Then_
Next
If j > Sqr(n) Then
_
End If
Next
Text1.Text = _
Text2.Text = _
End Sub

第1个回答  2013-11-18
n= [ 10+int(90*rnd) ]

st = [ st + " " + n ]

forj=2 to [ n ]

[ n1=n1+1 ]

[ exit for ]

text1.text=[ st ]

text2.text= [ n-n1 ]
第2个回答  2013-11-19
Private Sub Command1_Click()
Dim i As Integer, j As Integer, n As Integer, n1 As Integer, st As String
For i = 1 To 10
n =_
st = _
For j = 2 To _
If n Mod j = 0 Then_
Next
If j > Sqr(n) Then
_
End If
Next
Text1.Text = _
Text2.Text = _
End Sub本回答被网友采纳
相似回答