Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Label1.Text = "原始矩阵:" Label2.Text = "鞍点坐标:" Dim N, M, i, j, k As Integer N = InputBox("请输入矩阵行数", "输入") M = InputBox("请输入矩阵列数", "输入") Dim a(N, M) As Integer Randomize() '初始化原始矩阵 For i = 1 To N For j = 1 To M a(i, j) = (Rnd() * 20) Next Next '输出原始矩阵到Lable1 Label1.Text = Label1.Text & Chr(13) & Chr(10) For i = 1 To N For j = 1 To M Label1.Text = Label1.Text & a(i, j) & " " Next Label1.Text = Label1.Text & Chr(13) & Chr(10) Next '定义数组以存储行最大值,列最小值位置 Dim line(N, M + 1), list(N + 1, M) As Integer For i = 1 To N For j = 1 To M line(i, j) = 0 list(i, j) = 0 Next Next '找每行最大值,并将位置记入line矩阵中 Dim max As Integer = 0 For i = 1 To N For k = 2 To M max = 1 If a(i, max) < a(i, k) Then max = k End If Next line(i, k) = 1 Next '找每列最小值,并将位置记入list中 Dim min As Integer = 0 For j = 1 To M For k = 2 To N min = 1 If a(min, j) > a(k, j) Then min = k End If Next list(k, j) = 1 Next '判断鞍点 Dim u As Integer = 0 For i = 1 To N For j = 1 To M While line(i, j) And list(i, j) Label2.Text = Label2.Text & " " & "(" & i & "," & j & ")" u += 1 End While Next Next If u = 0 Then Label2.Text = Label2.Text & "此矩阵没有鞍点" End If End Sub End Class