Home > Back-end >  Help me to look at why always WS
Help me to look at why always WS

Time:09-27

Description
Given a 5 * 5 matrix, each line only a maximum, and each column only a minimum, looking for the saddle point of the matrix,
An element of the saddle point refers to the matrix, it is the same maximum value, and is the minimum value in the column,
For example: in the example below (line 4 elements of column 1 is a saddle point, value is 8),
11 3 5 6 9
12 4 7 8 10
5 6 9 10 11
8 June 4 July 2
15, 10, 11 20 to 25

Enter
Input contains a 5 line 5 columns of the matrix
O
If there is a saddle point, the output line saddle points, column and its value, if not, output "not found"
The sample input
11 3 5 6 9
12 4 7 8 10
5 6 9 10 11
8 June 4 July 2
15, 10, 11 20 to 25
Sample output
4 1 8





My code:
#include
#include
#include
using namespace std;

An int array [5] [5];
Int hang [5] [3].
Int lie [5] [3].
Int main ()
{
Int tmp1=0, tmp2=0, argu=0;
for(int i=0; i <5; I++)
{
For (int j=0; J<5; J++)
{
Cin> Array [I] [j];
}
}
For (int I=0; i <5; I++)
{
Int Max=array [0] [I], b=0, c=0;
For (int j=0; J & lt; 5; J++)
{
If (array [I] [j] & gt; Array [I] [0])
{
Max=array [I] [j];
C=j;
}
}
Hang [tmp1] [0]=Max;
Hang [tmp1] [1]=I;
Hang [tmp1] [2]=c;
Tmp1 + +;
}
For (int j=0; J & lt; 5; J++)
{
Int min=array [0] [j], e=0, f=0;
for(int i=0; i <5; I++)
{
If (array [I] [j] {
Min=array [I] [j];
E=I;

}
}
Lie [tmp2] [0]=min;
Lie [tmp2] [1]=e;
Lie [tmp2] [2]=j;
Tmp2 + +;
}
for(int i=0; i <5; I++)
{
For (int j=0; J & lt; 5; J++)
{

If (hang [I] [0]==lie [j] [0] & amp; & Hang [I] [1]==lie [j] [1] & amp; & Hang [I] [2]==lie [j] [2])
{
cout}
The else
{
Argu++;
}
}
}
If (argu==25)
{
cout<" Not found "& lt; }
return 0;
}
  • Related