VB 使显示每行的最大值的位置(下面的程序可以把最大值找出)Private Sub cmdbegin_Click() Dim a(4,3) As Integer,i As Integer,j As Integer Dim max As Integer For i = 1 To 4 For j = 1 To 3 a(i,j) = InputBox("请输入矩阵的第
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/09 05:05:59
VB 使显示每行的最大值的位置(下面的程序可以把最大值找出)Private Sub cmdbegin_Click() Dim a(4,3) As Integer,i As Integer,j As Integer Dim max As Integer For i = 1 To 4 For j = 1 To 3 a(i,j) = InputBox("请输入矩阵的第
VB 使显示每行的最大值的位置(下面的程序可以把最大值找出)
Private Sub cmdbegin_Click()
Dim a(4,3) As Integer,i As Integer,j As Integer
Dim max As Integer
For i = 1 To 4
For j = 1 To 3
a(i,j) = InputBox("请输入矩阵的第( " & i & " ," & j & " )元素","输入矩阵元素")
Picture1.Print a(i,j),
Next j
Picture1.Print
Next i
For i = 1 To 4
max = a(i,1)
For j = 2 To 3
If max < a(i,j) Then max = a(i,j)
Next j
Picture1.Print "第" & i & "行最大的是:"; max
Next i
End Sub
VB 使显示每行的最大值的位置(下面的程序可以把最大值找出)Private Sub cmdbegin_Click() Dim a(4,3) As Integer,i As Integer,j As Integer Dim max As Integer For i = 1 To 4 For j = 1 To 3 a(i,j) = InputBox("请输入矩阵的第
添加一个n作为标记
Dim n%
下面那个寻找最大数的循环改成这样:
For i = 1 To 4
max = a(i,1)
For j = 2 To 3
If max < a(i,j) Then
max = a(i,j)
n= j '以n标记出最大数所处的列
End if
Next j
Picture1.Print "第" & i & "行最大的是:"; max
Picture1.Print "其所处位置是第" & n & "列"
Next i