VB求平均值
Private Function pj(x() As Integer) As SingleDim m%, n%, i%, s%m = LBound(x): n = UBound(x)For i = m To ns = s + x(i)Next ipj = s / (n - m + 1)
End Function
Private Sub Command1_Click()Dim a%(1 To 10), i%, aver!For i = 1 To 10a(i) = Int(Rnd() * 10) '随机元素的值随机产生Print a(i);Next iPrintaver = pj(a)Print "这些数的平均值为:" & aver
End Sub