Answer the question
In order to leave comments, you need to log in
How to solve a problem with a two-dimensional array?
Create a square two-dimensional integer array (the number of rows and columns is the same), and using the loop(s) fill its diagonal elements with ones;
Hey! Help solve the problem, please. I just wrote this, but I don’t understand how
int[][] arr4 = new int[4][4];
for (int i = 0; i < arr4.length; i++) {
for (int j = 0; j < arr4.length; j++) {
}
}
Answer the question
In order to leave comments, you need to log in
In short, it is necessary to fill in units those cells for which i == j. Something in the spirit
if (i == j) {
arr4[i][j] = 1;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question