输入10个数,求这10个数中的最大值,最小值和平均值。(要用VB)
发布网友
发布时间:2022-05-18 12:07
我来回答
共1个回答
热心网友
时间:2023-10-16 08:43
Private Sub Form_Click() '点击窗体运行
Dim x As Long, i As Integer
Dim max As Long, min As Long, sum As Long, avg As Single
For i = 1 To 10
x = Val(InputBox("请输入第" & i & "个数"))
If i = 1 Or max < x Then max = x
If i = 1 Or min > x Then min = x
sum = sum + x
Next
avg = sum / 10
MsgBox "最大值=" & max & vbCrLf & "最小值=" & min & vbCrLf & "平均值=" & avg
End Sub