Randomize
Dim min As Integer: min = 101
Dim max As Integer
Dim sum As Integer
Dim a(20) As Integer
For i = 0 To 19
a(i) = 50 + Int(Rnd * 51)
If a(i) > max Then max = a(i)
If a(i) < min Then min = a(i)
sum = sum + a(i)
Next
MsgBox "最大值:" & max & vbCrLf & "最小值:" & min & vbCrLf & "平均值:" & sum / 20
Randomize(Timer)
Dim a(1 to 20) as Integer
Dim intC as Integer
For i=1 to 20
intC=CInt(Rnd()*(101-50)+50)
a(i)=intC
Next
然后用冒泡法求最大值、最小值。
平均值应该不用说了吧?
有什么问题欢迎随时交流。