VB编程题目: 随机产生10个0-100之间的整数放入数组,显示数组各元素的值,求出最大值,最小值和平均值。
1个回答
展开全部
Private Sub Command1_Click()
Dim a(9)
Randomize
Dim sum As Integer, min As Integer, max As Integer
sum = 0: min = 100: max = 0
For i = 0 To 9
a(i) = Int(101 * Rnd))
sum = sum + a(i)
If a(i) < min Then min = a(i)
If a(i) > max Then max = a(i)
Print a(i);
Next i
Print vbCrLf & "最大值:"; max
Print "最小值:"; min
Print "平均值:"; sum / 10
End Sub
Dim a(9)
Randomize
Dim sum As Integer, min As Integer, max As Integer
sum = 0: min = 100: max = 0
For i = 0 To 9
a(i) = Int(101 * Rnd))
sum = sum + a(i)
If a(i) < min Then min = a(i)
If a(i) > max Then max = a(i)
Print a(i);
Next i
Print vbCrLf & "最大值:"; max
Print "最小值:"; min
Print "平均值:"; sum / 10
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询