2个回答
展开全部
Private Sub Command1_Click()
Dim x(50) As Integer
Dim max As Integer
Dim min As Integer
Label1 = "产生的随机数"
max = 0
min = 20
For i = 1 To 50
x(i) = (Int(Rnd() * 50 + 1))
Label1 = Label1 + " " + Str(x(i))
If x(i) > max Then max = x(i)
If x(i) < min Then min = x(i)
Next i
Label2 = "最大值" + Str(max) + " " + "最小值" + Str(min)
End Sub
为了结果能生明显的变动,我把20以内改成50了,x(i) = (Int(Rnd() * 50 + 1))改成x(i) = (Int(Rnd() * 20 + 1))就是20以内了。
展开全部
Private Sub Command2_Click()
Dim a(50) As Integer, max As Integer, min As Integer
Dim i As Integer
For i = 1 To 50
Randomize
a(i) = Fix(Rnd * 20)
Next
For i = 1 To 50
If a(i) > max Then max = a(i)
Next
min = max
For i = 1 To 50
If a(i) < min Then min = a(i)
Next
For i = 1 To 50
Print a(i); ;
If i Mod 10 = 0 Then Print
Next
Print "最小值"; min
Print "最大值"; max
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询