用VB编写一个程序,计算出给定的10*10矩阵(存放在二维数组A中)每行元素的最大值和每列元素的最小值如果行元素中最大值的最小值大于列元素中最小值的最大值则输出“row”否则输出“col
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/06 07:48:43
用VB编写一个程序,计算出给定的10*10矩阵(存放在二维数组A中)每行元素的最大值和每列元素的最小值如果行元素中最大值的最小值大于列元素中最小值的最大值则输出“row”否则输出“col
用VB编写一个程序,计算出给定的10*10矩阵(存放在二维数组A中)每行元素的最大值和每列元素的最小值
如果行元素中最大值的最小值大于列元素中最小值的最大值则输出“row”否则输出“col”
用VB编写一个程序,计算出给定的10*10矩阵(存放在二维数组A中)每行元素的最大值和每列元素的最小值如果行元素中最大值的最小值大于列元素中最小值的最大值则输出“row”否则输出“col
Module Module1
Sub Main()
Dim A(,) As Integer = {{1,2,3,4,5,6,7,8,9,0},{1,2,3,4,5,6,7,8,9,0},{1,2,3,4,5,6,7,8,9,0},{1,2,3,4,5,6,7,8,9,0},{1,2,3,4,5,6,7,8,9,0},{1,2,3,4,5,6,7,8,9,0},{1,2,3,4,5,6,7,8,9,0},{1,2,3,4,5,6,7,8,9,0},{1,2,3,4,5,6,7,8,9,0},{1,2,3,4,5,6,7,8,9,0}}
Dim Rows(10) As Integer
Dim Cols(10) As Integer
Dim i,j As Integer
Dim max,min As Integer
For i = 0 To A.GetLength(0) - 1
Rows(i) = A(i,0)
For j = 0 To A.GetLength(1) - 1
If (A(i,j) > Rows(i)) Then
Rows(i) = A(i,j)
End If
Next
Next
For j = 0 To A.GetLength(1) - 1
Cols(j) = A(j,0)
For i = 0 To A.GetLength(0) - 1
If (A(i,j) < Cols(j)) Then
Cols(j) = A(i,j)
End If
Next
Next
min = Rows(0)
For i = 1 To A.GetLength(0) - 1
If Rows(i) < min Then
min = Rows(i)
End If
Next
max = Cols(0)
For i = 1 To A.GetLength(1) - 1
If Cols(i) > max Then
max = Rows(i)
End If
Next
If min > max Then
Console.WriteLine("row")
Else
Console.WriteLine("col")
End If
End Sub
End Module