C
C
ChronosX2018-10-07 16:32:41
Java
ChronosX, 2018-10-07 16:32:41

How to loop around a cell in a 2D array?

Actually, subject. I need to change the values ​​in a char[][] array around a cell. Is it possible to do so? It is desirable with check on an output from an array.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Denis Mamaev, 2018-10-08
@ChronosX

Nested loop on both coordinates from -1 to +1 from the current coordinate, why not?

C
Cheypnow, 2018-10-07
@Cheypnow

The question is, are cycles really necessary?
You can also calculate the coordinates of each cell and check for them whether they are within the boundaries of the array. 8 cells is not that much.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question