Dim x(100)
Private Sub Form_click()
dim I as long
For I = 0 To 99
x(I) = Rndz(0, 99)'生成随机数字,并赋值给数组
If x(I) < 50 Then Print x(I)'输出小于50的
Next
End Sub
Private Function Rndz(a As Long, b As Long)
Randomize
Rndz = Int((a - b + 1) * Rnd() + b)
End Function
Private Sub Form_Click()
Randomize
Dim A(100) As Integer
Dim I As Integer, K As Integer
Print "形成的100个数字的数组"
For I = 1 To 100
A(I) = Int(Rnd * 100)
Print A(I);
If I Mod 10 = 0 Then Print
Next
Print "其中<50的数字:"
K = 0
For I = 1 To 100
If A(I) < 50 Then
Print A(I);
K = K + 1
If K Mod 10 = 0 Then Print
End If
Next
Print "共有"; K; "个"
End Sub
已经运行过。有什么问题请留言。