vb题,用随机函数生成包含10个两位整数的一维数组,求这10个数的最大值,最小值以及平均值。
展开全部
Private Sub Command1_Click()
Dim a(10) As Integer
Dim max As Integer
Dim min As Integer
Dim avg As Double
Dim sum As Integer
sum = 0
Randomize
For i = 1 To 10
If i = 1 Then
a(i) = Int(Rnd * 90 + 10)
max = a(i)
min = a(i)
sum = sum + a(i)
Else
a(i) = Int(Rnd * 90 + 10)
If a(i) > max Then max = a(i)
If a(i) < min Then min = a(i)
sum = sum + a(i)
End If
Next i
Print "最大值是" & max
Print "最小值是" & min
Print "平均值是" & sum / 10
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询