急求VB编程“利用随机函数产生10个50-100之间的随机整数,求它们的最大值和平均值,要求用数组做”,谢谢
展开全部
Private Sub Command1_Click()
Randomize
Dim a(10) As Integer, imas as integer, imin as integer, Average as integer
imax = 49
imin = 101
Average=0
For i = 0 To 9
a(i) = Int(Rnd * 51) + 50
Average=Average+a(i)
If imax < a(i) Then imax = a(i)
If imin > a(i) Then imin = a(i)
Print a(i),
Next
Print
Print "最大值和最小值和平均值是:"; imax; imin; Average / 10
End Sub
楼上的平均值计算是错误的,并且循环多了一次
Randomize
Dim a(10) As Integer, imas as integer, imin as integer, Average as integer
imax = 49
imin = 101
Average=0
For i = 0 To 9
a(i) = Int(Rnd * 51) + 50
Average=Average+a(i)
If imax < a(i) Then imax = a(i)
If imin > a(i) Then imin = a(i)
Print a(i),
Next
Print "最大值和最小值和平均值是:"; imax; imin; Average / 10
End Sub
楼上的平均值计算是错误的,并且循环多了一次
展开全部
Private Sub Command1_Click()
Randomize
Dim a(10) As Integer
imax = 49
imin = 101
For i = 0 To 10
a(i) = Int(Rnd * 51) + 50
If imax < a(i) Then imax = a(i)
If imin > a(i) Then imin = a(i)
Print a(i),
Next
Print
Print "最大值和最小值和平均值是:"; imax; imin; (imax + imin) / 2
End Sub
Randomize
Dim a(10) As Integer
imax = 49
imin = 101
For i = 0 To 10
a(i) = Int(Rnd * 51) + 50
If imax < a(i) Then imax = a(i)
If imin > a(i) Then imin = a(i)
Print a(i),
Next
Print "最大值和最小值和平均值是:"; imax; imin; (imax + imin) / 2
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
private sub command1_click()
Randomize
n=rnd()*10
for i=1 to n
S=S+i
a=a+1/S ''这里应该注意!!!!!
next
msgbox "n值为"+str(n)+",结果为"+str(a)
end sub
Randomize
n=rnd()*10
for i=1 to n
S=S+i
a=a+1/S ''这里应该注意!!!!!
next
msgbox "n值为"+str(n)+",结果为"+str(a)
end sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你没给分啊!!吃白饭,不行咧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询