I am having an NxN matrix . I want to read the elements of that NxN matrix diagonally and need to store it in an array.How?
For example, I am having one 3x3 matrix
$$\begin{bmatrix} A B C \\ D E F\\ G H I \end{bmatrix}$$
I want to read this matrix diagonally(starting from A and downwards) and output should be
A D B C E G H F I
Update:
How can i do it in reverse manner?
I want to fill the above read array(A D B C E G H F I) into an NxN (N should be given as input) HOW?