I am trying to find indexes in a 2D array where the number x is either larger than the numbers left and right, and smaller than the numbers above and below, or vice versa.
Find indexes in 2d array with if parameters
Collapse
X
-
A general algorithm may be:
1: Input the 2D array.
2: Start a loop to initialise the values of array from [0][0] to [0][1]...
3:
Another loop to extract array values
{
-Checking if the value of current element a[i][j] is the largest in current horizontal row (keeping 'i' same)
If so
{ Copy the value of 'j' to another variable.
Now keeping the 'j' same, check whether the current element has the lowest value in its column or not( [0][5], [1][5],...).
If yes, copy the value of 'i' to another variable.}
Now print the value of array element using array[new_var_1][new_var_2] and the new variable's values will be the indices values.
}
Comment