求高手给做一VB变成题,谢谢!

来源:百度知道 编辑:UC知道 时间:2024/06/13 02:57:18
有一个N*M的矩阵,编写程序,找出其中最大的元素所在的行和列,并输出其值及行号和列号。

Option base 1
private sub form_click()
dim ma() as integer
dim N,M as integer
N=inputbox("请输入矩阵的行数")
M=inputbox("请输入矩阵的列数")
dim ma(N,M) as integer
for i=1 to N
for j=1 to M
ma(i,j)=inputbox("请输入数组第"&str(i)&"行第"&str(j)&"列元素值")
next j
next i
print"所建的矩阵为:"
for i=1 to N
for j=1 to M
print ma(i,j);
next j
print
next i
ma=ma(1,1)
for i=1 to N
for j=1 to M
if max<ma(i,j) then
max=ma(i,j)
column=j
row=i
end if
next j
next i
print
print"矩阵最大的元素的值为:";ma(row,column)
print"它所在的行号为:";row;",列号为:";column
end sub

Private Sub Form_click()
Dim n As Integer, m As Integer, a() As Variant, max As Integer
max = 0
n = Val(InputBox(""))
m = Val(InputBox(""))
ReDim a(n, m)
For i = 1 To n
For j = 1