Find indexes in 2d array with if parameters

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mcfellows
    New Member
    • Mar 2017
    • 1

    #1

    Find indexes in 2d array with if parameters

    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.
  • dev7060
    Recognized Expert Contributor
    • Mar 2017
    • 656

    #2
    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

    Working...