vb编程练习题
求一个矩阵中的最大的数,这是参考答案,但是不明白和max=-32768比较的原理是什么,求解。Submain()DimmAsInteger,nAsIntegerDima(...
求一个矩阵中的最大的数,这是参考答案,但是不明白和max=-32768比较的原理是什么,求解。
Sub main()
Dim m As Integer, n As Integer
Dim a() As Integer, i As Integer, j As Integer
Dim max As Integer, i1 As Integer, j1 As Integer
Open "in.txt" For Input As #1
Open "out.txt" For Output As #2
Input #1, m, n
ReDim a(m, n)
max = -32768
For i = 1 To m
For j = 1 To n
Input #1, a(i, j)
If a(i, j) > max Then
max = a(i, j)
i1 = i
j1 = j
End If
Next j
Next i
Print #2, i1; j1
Close #1, #2
End Sub 展开
Sub main()
Dim m As Integer, n As Integer
Dim a() As Integer, i As Integer, j As Integer
Dim max As Integer, i1 As Integer, j1 As Integer
Open "in.txt" For Input As #1
Open "out.txt" For Output As #2
Input #1, m, n
ReDim a(m, n)
max = -32768
For i = 1 To m
For j = 1 To n
Input #1, a(i, j)
If a(i, j) > max Then
max = a(i, j)
i1 = i
j1 = j
End If
Next j
Next i
Print #2, i1; j1
Close #1, #2
End Sub 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询