I wanted to know how to check the diagonal of a particular index, for example, put 1 in all diagonal numbers of row 2, column 2
0 1 0 1
0 0 1 0
0 1 0 1
1 0 0 0
I wanted to know how to check the diagonal of a particular index, for example, put 1 in all diagonal numbers of row 2, column 2
0 1 0 1
0 0 1 0
0 1 0 1
1 0 0 0
If you have a value whose index would be [x] [y], then the diagonals will have the indices [x-1] [y-1], [x + 1] [y-1], [x-1 ] [y + 1] and [x + 1] [y + 1], put this inside a try ... catch with an ArrayIndexOutOfBoundsException for an index that does not exist (for example, if you check a house in the corners, then you will only have 1 or 2 diagonals to the 4th of the 4)
I believe you just go through the array by checking where the line is equal to the column and put 1 in those lines.
for(i=1;i<=n;i++){
for(j=1;<=n;j++){
if( i == j){
m[i][j] = 1;
}
}
}
I recommend you to do some research here because I believe you have something similar posted here already.