五笔打字通主页
VB程序题:随机产生30-100(包括30、100)的10个正整数,求最大值,最小值,平均值,并显示整个数组的值和结果,如下图所示。
解题,代码如下:
Private Sub Form_Click()
Dim a(1 To 10) As Integer
For i = 1 To 10
a(i) = Int(Rnd * 71 + 30)
Print a(i); " ";
Next i
Max = a(1)
Min = a(1)
Avg = a(1)
For i = 2 To 10
If a(i) > Max Then Max = a(i)
If a(i) < Min Then Min = a(i)
Avg = Avg + a(i)
Next i
Avg = Avg / 10
Print
Print "Max="; Max; " Min="; Min; " Avg="; Avg
End Sub
Visual Basic程序设计教程(第3版) (龚沛曾等编)课后实验源码
来源:济亨网
本文链接:http://wb86.com/post/79.html