VB编程题:求二维数组a(m,n)中的最大值以及最大值所在的行号和列号,行数m、列数n及数组元素从键盘输入;

请用VB的方法解答,谢谢
2024-11-08 17:10:10
推荐回答(1个)
回答(1):

Private Sub Command1_Click()
Dim a() As Integer
m = InputBox("请输入行数m:")
n = InputBox("请输入列数n:")
ReDim a(m, n)
For i = 1 To m
For j = 1 To n
a(i, j) = InputBox("请输入a(" & i & "," & j & ")")
Print a(i, j);
Next j
Print
Next i
Max = a(1, 1)
For i = 1 To m
For j = 1 To n
If Max < a(i, j) Then
Max = a(i, j)
x = i
y = j
End If
Next j
Next i
Print
Print "最大值为" & Max & "在第" & x & "行" & y & "列"
End Sub