设计程序VB随机产生20个10到100之间(包括10和100)的整数,按每行五个输出,同时找出其中的最大值并输出

2024-12-16 05:50:33
推荐回答(4个)
回答1:

'设计程序VB随机产生20个10到100之间(包括10和100)的整数,按每行五个输出,同时找出其中的最培棚返大值并输出
Private Sub Command1_Click()
On Error Resume Next
Dim a(5) As Integer
Randomize
'Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
For i = 0 To 3
b = ""
c = 0
For j = 1 To 5
a(j) = Int((100 - 10 + 1) * Rnd + 10)
b = b & " " & a(j)
Next
c = a(1)
If c < a(2) Then c = a(2)
If c < a(3) Then c = a(3)
If c < a(4) Then c = a(4)
If c < a(5) Then c = a(5)
Print b & "配饥 最大和枣数为:" & c
Next
End Sub

回答2:

Option Explicit
Private Sub Command1_Click()
Randomize Timer
Dim i As Byte, max As Byte, min As Byte, irnd As Byte
min = 255
For i = 1 To 20
irnd = 10 + Int(Rnd * 91)
If irnd >芦拦 max Then max = irnd
If irnd < min Then min = irnd
Print Format(irnd, "@@@ "橘卖);
If i Mod 5 = 0 Then Print
Next
Print "max num:"; max; "陪伍胡 min num:"; min

End Sub

回答3:

Private Sub Form_Click()
Dim I, J, A(20) As Integer
Randomize
A(0) = Int(Rnd() * 91 + 10)
J = A(0)
Print A(0); " ";
For I = 1 To 19
A(I) = Int(Rnd() * 91 + 10)
If I Mod 5 = 0 Then Print
Print A(I); " ";
If J < A(I) Then J = A(I)
Next I
Print
Print "最敏滚大值="磨拿册瞎宏; J
End Sub

回答4:

Private Sub Command1_Click()
Dim a(21) As Integer, s As String
Dim i As Integer, m As Integer
Randomize
For i = 1 To 20
a(i) = Int(90 * Rnd + 10)
s = s & "让缺 " & a(i)
If i Mod 5 = 0 Then
s = s & Chr(13)
End If
Next i
m = a(1)
For i = 2 To 20
If m < a(i) Then m = a(i)
Next i
Print
Print "随轿滑乎机数为:" & Chr(13) & s
Print "闭悉最大数:" & m
End Sub