VB随机产生数组
设计程序,随机产生64个从100-999范围内的整数,存放在8*8的数组中,然后在该数组中找出最大值的元素(若右多个最大元素,只需找出其中一个),并输入其值及行号列号(行...
设计程序,随机产生64个从100-999范围内的整数,存放在8*8的数组中,然后在该数组中找出最大值的元素(若右多个最大元素,只需找出其中一个),并输入其值及行号列号(行号列号都从1开始算)
展开
2个回答
展开全部
Private Sub Command1_Click()
Dim a(1 To 8, 1 To 8) As Integer
Dim i, j As Integer
Dim max, m, n As Integer
max = 0
For i = 1 To 8
For j = 1 To 8
a(i, j) = Int((999 - 100 + 1) * Rnd + 100)
If a(i, j) > max Then
max = a(i, j)
m = i
n = j
Else
max = max
End If
Next
Next
MsgBox max & " 行 : " & m & " 列 : " & n
End Sub
Dim a(1 To 8, 1 To 8) As Integer
Dim i, j As Integer
Dim max, m, n As Integer
max = 0
For i = 1 To 8
For j = 1 To 8
a(i, j) = Int((999 - 100 + 1) * Rnd + 100)
If a(i, j) > max Then
max = a(i, j)
m = i
n = j
Else
max = max
End If
Next
Next
MsgBox max & " 行 : " & m & " 列 : " & n
End Sub
展开全部
Randomize
Dim m(8, 8) As Integer
Dim mx As Integer, mr As Integer, mc As Integer
For i = 1 To 8
For j = 1 To 8
m(i, j) = Rnd * 899 + 0.5 + 100
If m(i, j) > mx Then
mx = m(i, j)
mr = i
mc = j
End If
Next j
Next i
MsgBox "最大数是" & mx & ",在第" & mr & "行,第" & mc & "列"
Dim m(8, 8) As Integer
Dim mx As Integer, mr As Integer, mc As Integer
For i = 1 To 8
For j = 1 To 8
m(i, j) = Rnd * 899 + 0.5 + 100
If m(i, j) > mx Then
mx = m(i, j)
mr = i
mc = j
End If
Next j
Next i
MsgBox "最大数是" & mx & ",在第" & mr & "行,第" & mc & "列"
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询