vb程序设计“生成10个二位数,求出其中的最大值、最小值、平均值,并指出最大最小值是第几个随机数”
2013-05-08
展开全部
Private Sub Command1_Click()
Dim max, min, pj, a(1 To 10)
pj = 0
max = 0
min = 100
Randomize
Print "产生的10个数为:";
For i = 1 To 10
a(i) = Int(Rnd(1) * 90 + 10)
If a(i) > max Then max = a(i)
If a(i) < min Then min = a(i)
pj = pj + 0.1 * a(i)
Print a(i);
Next i
Print
Print "最大数为:", max
Print "最小数为:", min
Print "平均数为:", pj
End Sub
Dim max, min, pj, a(1 To 10)
pj = 0
max = 0
min = 100
Randomize
Print "产生的10个数为:";
For i = 1 To 10
a(i) = Int(Rnd(1) * 90 + 10)
If a(i) > max Then max = a(i)
If a(i) < min Then min = a(i)
pj = pj + 0.1 * a(i)
Print a(i);
Next i
Print "最大数为:", max
Print "最小数为:", min
Print "平均数为:", pj
End Sub
2013-05-08
展开全部
Private Sub Command1_Click()
Dim n(1 To 10), max, min, i As Integer
Dim q, w, s As Integer
s = 0
For i = 1 To 10
Randomize
n(i) = Int(Rnd * 90 + 10)
Print n(i)
Next i
max = n(1)
min = n(1)
For i = 1 To 10
If n(i) > max Then
max = n(i)
q = i
End If
If n(i) < min Then
min = n(i)
w = i
End If
s = s + n(i)
Next i
Print "最大为第" & q & "位,为:" & max; " 最小为第" & w & "位,为:" & min
Print "平均数为:"; s / 10
End Sub
Dim n(1 To 10), max, min, i As Integer
Dim q, w, s As Integer
s = 0
For i = 1 To 10
Randomize
n(i) = Int(Rnd * 90 + 10)
Print n(i)
Next i
max = n(1)
min = n(1)
For i = 1 To 10
If n(i) > max Then
max = n(i)
q = i
End If
If n(i) < min Then
min = n(i)
w = i
End If
s = s + n(i)
Next i
Print "最大为第" & q & "位,为:" & max; " 最小为第" & w & "位,为:" & min
Print "平均数为:"; s / 10
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询