Searching a 2D array for a range of values in java

Posted by Paige O on Stack Overflow See other posts from Stack Overflow or by Paige O
Published on 2013-11-03T21:45:57Z Indexed on 2013/11/03 21:54 UTC
Read the original article Hit count: 249

Filed under:
|
|
|

I have a 2^n size int array and I want to check if an element exists that is greater than 0. If the element exists, I want to divide the array by 4 and check if the coordinates of the found element are in the 1st, 2nd, 3rd or 4th quadrant of the array.

For example, logically if the element exists in the first quadrant it would look something like this:

If array[][] > 0 && the row of that coordinate is in the range 0-(grid.length/2-1) && the column of that coordinate is in the range 0-(grid.length/2-1) then do something.

I'm really not sure how to check the row and column index of the found element and store those coordinates to use in my if statement. Help!

© Stack Overflow or respective owner

Related posts about java

Related posts about arrays