设计程序VB随机产生20个10到100之间(包括10和100)的整数,按每行五个输出,同时找出其中的最大值并输出 10
4个回答
展开全部
'设计程序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
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
展开全部
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
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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
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 "最大值="; J
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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
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 "随机数为:" & Chr(13) & s
Print "最大数:" & m
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询