Two-dimensional array to find a saddle point

Two-dimensional array to find a saddle point (saddle point is the largest row, a minimum number of columns)

A "saddle point" refers to the maximum matrix element value of the element at that position, the minimum on the column on the line.
This problem requires programming, seeking a given n-order square matrix saddle point.
Input formats:

The first input line is given a positive integer n (1≤n≤6). Then n lines of n integers are given, separated by a space therebetween.
Output formats:

Output in "lower line marked column index" (index starting from 0) of the output format saddle point position in a row. If the saddle point does not exist, the output "NONE". Title ensure a given matrix at most one saddle point.
Sample Input 1:

4
1 7 4 1
4 8 3 6
1 6 1 2
0 7 8 9

Output Sample 1:

2 1

Sample Input 2:

2
1 7
4 1

Output Sample 2:

NONE

/ Let me talk about my idea is, the maximum value of the line first with a two-dimensional array to store the two-dimensional array, respectively, minimum and columns, and then after comparing her two nested loops are equal under equal conditions in , the location where the index is a saddle point of /
now provides the core code, the first step is to find someone to travel the maximum and minimum column of

this step is to assume that most small difficulty value initial question, it is worth noting that circulation problems ;
the second step is the final step is to compare the use of nested loops to compare the output can be found directly saddle point.
In the process of writing, the idea is that, compare, and then find the value of the saddle point, and then re-use that value to find its place in a two-dimensional array, but there is a wrong point is, there is likely to encounter duplicate , this time on the wrong index, so the use of nested loops, looking for the process may further output index at any time.

FIG attached through test points

The idea into a flow chart

Guess you like

Origin www.cnblogs.com/hlt99/p/12051045.html