VB利用随机函数生成50-100范围内20个随机数,显示最大值,最小值,平均值,求代码,求窗体

哪位大神给下代码和窗体可好 谢谢
2024-12-18 10:34:32
推荐回答(1个)
回答1:

Private Sub Form_Activate()
Dim a(1 To 20) As Integer, b As Integer, c As Integer, d As Integer, e As Integer
Randomize
Print "随机数:";
For i = 1 To 20
a(i) = Int(Rnd * 50) + 50
If a(i) > d Then d = a(i)
e = e + a(i)
Print a(i);
Next
c = a(1)
For i = 2 To 20
If c > a(i) Then c = a(i)
Next
Print
Print "最小值为:"; c
Print "最大数为:"; d
Print "平均值为:"; e / i
End Sub