//求鞍点
#include <stdio.h>
#define row 3
#define col 4
int main()
{
int arr[row][col]={1,2,3,4,5,6,7,8,9,10,11,12};
int SaddlePoints;
int i,j,k;
int rmax,cmax;//记录行最大元素的行数和列数;
int flag; //若存在一个鞍点则令为1;
for(i = 0;i < row; i++)
{
SaddlePoints=arr[i][0];
rmax=i;
cmax=0;
for(j = 1;j< col;j++)
{
if(SaddlePoints<arr[i][j])
{
SaddlePoints=arr[i][j];
cmax=j;
}
}//找到行最大
for(k = 0;k<row;k++)
{
if(SaddlePoints>arr[k][j]&&k!=i)
break;
}
if(k==row)//说明已经将列全部检索
{
flag=1;
printf("SaddlePoint is A[%d][%d]=%d\n",i,j,SaddlePoints);
}
}
if(flag=0)
printf("There's no SaddlePoints!");
return 0;
}
求鞍点
最新推荐文章于 2023-11-26 14:33:58 发布