You know the transpose of a matrix is defined this way:
A
Tij = A
ji
That implies that, for instance, a
2x3
matrix, transposed, will become
3x2
.
Suppose the input matrix is represented by an array
a
having dimensions
M,N
, your code has to:
- Create a new array, say
b
, having dimensions N,M.
- Set all the new array items according to the above rule, namely
b[i][j] = a[j][i]
.
That's all.