编一VB程序,随机产生10个30~100(包括30,100)的正整数,求最大值,最小值和平均值,并显示整个数组的值和结果
2个回答
展开全部
Private Sub Command1_Click()
Dim a(10)
Randomize
Dim sum As Integer, min As Integer, max As Integer
sum = 0: min = 100: max = 30
For i = 0 To 9
a(i) = Int(30 + (71 * 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(10)
Randomize
Dim sum As Integer, min As Integer, max As Integer
sum = 0: min = 100: max = 30
For i = 0 To 9
a(i) = Int(30 + (71 * 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
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Dim a(10)
Randomize
Dim sum As Integer, min As Integer, max As Integer
sum = 0: min = 100: max = 30
For i = 0 To 9
a(i) = Int(30 + (71 * 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(10)
Randomize
Dim sum As Integer, min As Integer, max As Integer
sum = 0: min = 100: max = 30
For i = 0 To 9
a(i) = Int(30 + (71 * 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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询