Hi,
I am new. I did my my best to read the rules first so please pardon me if i missed any.
My qestion is in regards to filling up a matrix diagonally:
"Write a method that accepts a square matrix. Assume that the size of the matrix is declared as an instance constant. Fill the array with successive integers as illustrated below by the case when the size is four.
1 3 6 10
2 5 9 13
4 8 12 15
7 11 14 16
This question is meant to refine your ability to fill in the matrix programmatically, not when you declare the array. So please, do not manually fill in the array when you create it.
The code i worked on so far:
public static void main(String[]args){
int arrTwo[ ][ ] = new int [4][4];
for(int i = 0; i < arrTwo.length; i++)
{
for(int j =0; j < arrTwo[0].length; j++)
{
System.out.print(arrTwo[i][j] + " ");
}
System.out.println();
}
}
Thank you for any help.