3
$\begingroup$

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?

  • 1
    Hint: Note that on a diagonal as you define it, the sum of the indices of an array component is always the same.2011-02-16
  • 0
    can i get the logic in an equation form?2011-02-16
  • 0
    OK, I'll cook something up, just give me some time.2011-02-16
  • 0
    OK sure. I am waiting for your reply. Finally I am implementing the logic using C langauage.2011-02-16
  • 2
    in any case, this is *not* a mathematical question: you should have asked on the programming site...2011-02-16

2 Answers 2