VB编程题目: 随机产生10个0-100之间的整数放入数组,显示数组各元素的值,求出最大值,最小值和平均值。

如题所述

第1个回答  2011-06-15
Private Sub Command1_Click()
Dim a(9)
Randomize
Dim sum As Integer, min As Integer, max As Integer
sum = 0: min = 100: max = 0
For i = 0 To 9
a(i) = Int(101 * Rnd))
sum = sum + a(i)
If a(i) < min Then min = a(i)
If a(i) > max Then max = a(i)
Print a(i);
Next i
Print vbCrLf & "最大值:"; max
Print "最小值:"; min
Print "平均值:"; sum / 10

End Sub本回答被提问者采纳
相似回答