求大神解答一道VB编程题,如图实验内容第1题,在线等,急,可追加悬赏!
Private Sub Form_Click()
Dim i As Integer
Dim a(10) As Integer
For i = 1 To 10
a(i) = Rnd * 100
Next
Call Sortnum(a, 10)
For i = 1 To 10
Print a(i);
Next
Print "Max:" & MaxNum(a, 10)
Print "Ave:" & AveNum(a, 10)
End Sub
Function MaxNum(a() As Integer, n) As Integer
Dim i As Integer, m As Integer
m = a(1)
For i = 1 To n
If m < a(i) Then m = a(i)
Next
MaxNum = m
End Function
Function AveNum(a() As Integer, n) As Single
Dim i As Integer, m As Single
m = 0
For i = 1 To n
m = m + a(i)
Next
AveNum = m / 10
End Function
Sub Sortnum(a() As Integer, n)
Dim i As Integer, j As Integer, t As Integer
For i = 1 To n
For j = i To n
If a(i) > a(j) Then
t = a(i)
a(i) = a(j)
a(j) = t
End If
Next
Next
End Sub