#include<stdio.h>
int main()
{
int a[3][4];
int row; //设置列标
int col; //设置行标
int saddlepoint;
for(int i=0; i<3; i++)
for(int j=0; j<4; j++)
scanf("%d", &a[i][j]);
int flag; //设置标志位
for(int x=0; x<3; x++)
{
saddlepoint = a[x][0];//先将鞍点初始化为该行第一个元素
//找改行最大值
for(int y=0; y<4; y++)
{
if(saddlepoint<a[x][y])
{
saddlepoint = a[x][y];
col = y;
row = x;
}
}
flag = 1;
//判断该行最大值是否为该列最大值
for(int k=0; k<3; k++)
{
if(a[k][col] < saddlepoint)
flag = 0;
}
//找到鞍点后立刻结束循环,以防影响flag的判断
if(flag == 1)
{
printf("saddlepoint: %d, col: %d, row:%d ", saddlepoint, col, row);
break;
}
}
if(flag == 0)
printf("no saddlepoint");
}
活到老,学到老
flag标志位的设立