4 个解决方案
#1
这是基础知识啊
#2
请大家帮下忙
#3
Private Sub Form_Load()
Dim Arr(9) As Integer
Dim MyValue, i As Integer
Form1.Show
For i = 0 To 9
Randomize
MyValue = Int((81 * Rnd) + 20)
Arr(i) = MyValue
Print MyValue
t = t + MyValue
Next
Print "平均值为" & t / 10
maxmin Arr
End Sub
Private Function maxmin(x() As Integer)
Dim n1 As Integer, n2 As Integer
Dim i As Integer
n1 = UBound(x)
n2 = LBound(x)
maxnumber = x(n1)
minnumber = x(n2)
For i = n2 + 1 To n1
If x(i) > maxnumber Then
maxnumber = x(i)
End If
Next i
For i = n2 + 1 To n1
If x(i) < minnumber Then
minnumber = x(i)
End If
Next i
Print "最大值为" & maxnumber
Print "最小值为" & minnumber
End Function
#4
很多谢老张,SYSSZ,能抽时间帮我解决问题,且那个函数写得好,呵呵,我给的分确实有点低,多谢
#1
这是基础知识啊
#2
请大家帮下忙
#3
Private Sub Form_Load()
Dim Arr(9) As Integer
Dim MyValue, i As Integer
Form1.Show
For i = 0 To 9
Randomize
MyValue = Int((81 * Rnd) + 20)
Arr(i) = MyValue
Print MyValue
t = t + MyValue
Next
Print "平均值为" & t / 10
maxmin Arr
End Sub
Private Function maxmin(x() As Integer)
Dim n1 As Integer, n2 As Integer
Dim i As Integer
n1 = UBound(x)
n2 = LBound(x)
maxnumber = x(n1)
minnumber = x(n2)
For i = n2 + 1 To n1
If x(i) > maxnumber Then
maxnumber = x(i)
End If
Next i
For i = n2 + 1 To n1
If x(i) < minnumber Then
minnumber = x(i)
End If
Next i
Print "最大值为" & maxnumber
Print "最小值为" & minnumber
End Function
#4
很多谢老张,SYSSZ,能抽时间帮我解决问题,且那个函数写得好,呵呵,我给的分确实有点低,多谢