VB的代码程序设计,懂的进。 题目求10个30—100间的随机正整数中的最大值,最小值,平均值
要求如下:(1)定义一个一维数组存放随机产生的30-100之间的10个正整数。(2)30-100间的随机整数Int(Rnd*71+30)(3)分别定义变量用来表示最大值,...
要求如下:(1)定义一个一维数组存放随机产生的30-100之间的10个正整数。 (2)30-100间的随机整数Int(Rnd*71+30)(3)分别定义变量用来表示最大值,最小值和平均值
展开
2013-06-16
展开全部
Private Sub Form_Load()
Dim a(9) As Integer
Dim i As Integer
Dim sum As Integer
Dim min As Integer
Dim max As Integer
Dim avg As Double
sum = 0
Randomize
a(0) = Int(Rnd * 71 + 30)
min = a(0)
max = a(0)
For i = 1 To 9
a(i) = Int(Rnd * 71 + 30)
Print a(i)
If min > a(i) Then
min = a(i)
End If
If max < a(i) Then
max = a(i)
End If
sum = sum + a(i)
Next i
avg = sum / 10
Print "最大数是" & max
Print "最小数是" & min
Print "平均数是" & avg
End Sub
Dim a(9) As Integer
Dim i As Integer
Dim sum As Integer
Dim min As Integer
Dim max As Integer
Dim avg As Double
sum = 0
Randomize
a(0) = Int(Rnd * 71 + 30)
min = a(0)
max = a(0)
For i = 1 To 9
a(i) = Int(Rnd * 71 + 30)
Print a(i)
If min > a(i) Then
min = a(i)
End If
If max < a(i) Then
max = a(i)
End If
sum = sum + a(i)
Next i
avg = sum / 10
Print "最大数是" & max
Print "最小数是" & min
Print "平均数是" & avg
End Sub
2013-06-16
展开全部
VB6.0代码:(通过单击窗体)Private Sub Form_Click()
Dim a(9) As Integer, i As Integer, max As Integer, min As Integer, ave As Integer, sum As Integer
sum = 0
a(0) = Int(Rnd(1) * 71 + 30)
min = a(0)
max = a(0)
For i = 1 To 9
a(i) = Int(Rnd(1) * 71 + 30)
Print a(i);
sum = sum + a(i)
If a(i) > max Then
max = a(i)
End If
If a(i) < min Then
min = a(i)
End If
Next i
Print
ave = sum / 10
Print "×�0�6�0�7ó�0�0�0�8�0�2�0�9:" & max
Print "�0�6�0�4�0�3�0�0�0�8�0�2�0�9:" & min
Print "�0�4�0�5�0�6ù�0�0�0�8�0�2�0�9:" & ave
End Sub
Dim a(9) As Integer, i As Integer, max As Integer, min As Integer, ave As Integer, sum As Integer
sum = 0
a(0) = Int(Rnd(1) * 71 + 30)
min = a(0)
max = a(0)
For i = 1 To 9
a(i) = Int(Rnd(1) * 71 + 30)
Print a(i);
sum = sum + a(i)
If a(i) > max Then
max = a(i)
End If
If a(i) < min Then
min = a(i)
End If
Next i
ave = sum / 10
Print "×�0�6�0�7ó�0�0�0�8�0�2�0�9:" & max
Print "�0�6�0�4�0�3�0�0�0�8�0�2�0�9:" & min
Print "�0�4�0�5�0�6ù�0�0�0�8�0�2�0�9:" & ave
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-06-16
展开全部
dim rand(10)
total=0
min=100
max=0str=""
for i=1 to 10
Randomize
rand(i)=Int(Rnd*71+30) '产生随机数
total=total+rand(i)
if min>rand(i) then min=rand(i)
if max<rand(i) then max=rand(i)
next
str=str&"产生的随机数是:"
for i=1 to 10
if i<10 then
str=str&rand(i)&","
else
str=str&rand(i)&""
end if
next
str=str&"其中最大数为:"&max
str=str&",其中最小数为:"&min
str=str&",平均数为:"&total/10
total=0
min=100
max=0str=""
for i=1 to 10
Randomize
rand(i)=Int(Rnd*71+30) '产生随机数
total=total+rand(i)
if min>rand(i) then min=rand(i)
if max<rand(i) then max=rand(i)
next
str=str&"产生的随机数是:"
for i=1 to 10
if i<10 then
str=str&rand(i)&","
else
str=str&rand(i)&""
end if
next
str=str&"其中最大数为:"&max
str=str&",其中最小数为:"&min
str=str&",平均数为:"&total/10
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询