Answer the question
In order to leave comments, you need to log in
A two-dimensional checkerboard array?
I'm just learning Java and immediately ran into a dead end in a task.
It is necessary to display a two-dimensional array in the form of a chessboard, but not simply, but in this form:
I know how to display a two-dimensional array in the form of a board, but alternating each cell, but this does not work. I guess I should use if and modulo division... help!
Here is my output:
int[][] mas = new int[24][24];
for(int i = 0; i < mas.length; i++) {
for(int j=0; j < mas.length; j++) {
if((i+j)%2 == 0) mas[i][j] +=1;
System.out.print(" " + mas[i][j]);
}
System.out.println();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question