2019: Saddle Point calculationTime limit: 1 Sec memory limit: MB
Submitted: 66 Settlement: 30
Topic Description
Find the "saddle point" with a two-dimensional array of m rows n columns, where the element is the largest on the row, the smallest on the column, where 1<=m,n<=10. input
The input data has more than one row, the first row has two numbers m and N, the following has M row, each row has n number. Output
The saddle points are output in the following format: Array[i][j]=x where x represents the saddle point, I and J are the array row and column subscript for the saddle point, we specify that the array subscript start from 0. A two-dimensional array does not necessarily have a saddle point, so please output none at this time. We guarantee that there will be no two saddle points, such as:
3 3
1 2 3
1 2 3
3 6 8 Sample input
3 3
1 2 3 4 5 6 7 8 9
Sample Output
Array[0][2]=3
lost in the valley of the birds, flying alone in this huge world, but do not know where to fly to the side ...
#include <stdio.h>
int main ()
{
int n,m,a[99][99],i,j,max,maxj;
BOOL Flag;
scanf ("%d%d", &n,&m);
For (i=0 i<n; i++) for
(j=0; j<m; j + +)
scanf ("%d", &a[i][j]);
for (i=0; i<n; i++)
{
max=a[i][0];
maxj=0;
For (j=0 j<m; j + +)
if (Max<a[i][j])
{
max=a[i][j];
maxj=j;
}
Flag=true;
for (int k=0; k<n; k++)
if (Max>a[k][maxj])
{
flag=false;
Continue;
}
if (flag)
{
printf ("array[%d][%d]=%d", I,maxj,max);
break;
}
}
if (!flag) printf ("none\n");
return 0;
}