实验名称:鞍点
一、实验目的:找出这一行中最大的数,且保证这个数是这一列的最小值
二、实验编程:
Option Base
Dim anma() As Integer
Dim m As Byte,n As Byte
Private Sub command1_click()
Cls
Me.font.size=30
Dim i As Byte,j As Byte
||生成二维数组
m=5,n=6
Redim anma(m,n)
||此时数组里全是0,我们用一个双重循环来赋初值i—m,j—n.
Dim i As Byte,j As Byte
For i =1 to m
Forj=1 to n
anma(i,j)=10+Int(Rnd*90)
print anma(i,j);Spc(3);
Next j
Next i
||当k是小于或者等于m时,证明row_max不是该列最小值;当k=m+1时,则row_max是鞍点
||row_max表示当前行上的最大值;column表示所找到的最大值所在的列号
Dim row_max As Integer, column_max As Byte
For i =1 to m
row_max=anma(i,1)
column_max=1
For j=2 To n
Ifanma(i,j)> row_max Then
row_max= anma(i,j)
column_max=j
End if
Next j
For k=1 To m
If anma(k, column_max)<row_max Then
Exit For
End if
Next k
If k=m+1 Then
Print“鞍点;”&i&”,”&column_max
End if
Next i
End sub