Given an

MxN matrix A, the transpose of A can be found by mapping each (i,j) entry of A to the (j,i) position of its transpose. For instance:

Given |1 2 3|
A = |4 5 6|
|7 8 9|

for i=j=1, the (1,1) entry of A is 1 and therefore the (1,1) position in Atranspose is 1.

for i-1,j=2 the (1,2) entry of A is 2 and therefore the (2,1) position in Atranspose is 2.

for i=1,j=3 the (1,3) entry of A is 3 and therefore the (3,1) position in Atranspose is 3.

for i=2,j=1 the (2,1) entry in A is 4 and therefore the (1,2) position in Atranspose is 4.

for i=2,j=2 the (2,2) entry in A is 5 and therefore the (2,2) position in Atranspose is 5.

for i=2,j=3 the (2,3) entry in A is 6 and therefore the (3,2) position in Atranspose is 6.

In the end we have:
|1 4 7|
Atranspose = |2 5 8|
|3 6 9|