How to transpose a 2D array

From

1,2.3,4

5,6,7,8

9,10,11,12

13,14,15,16

To

1 5 9 13

2 6 10 14

3 7 11 15

4 8 12 16

Is it more easy to use 1D array than 2D array to transpose?

I know that i use for loop as below it will display every row from 0 to 3,

but how to put in the expression in the for loop so that i can apply the logic inside?

for(int a = 0; a < 4; a++)

{

for(int b = 0; b < 4; b++)

{

group [a][b] = a + b +1;

}

}

I know that to dislay the result below i must

Logic

1,2.3,4 (a+b+1)

5,6,7,8 (a+b+4)

9,10,11,12 (a+b+7)

13,14,15,16 (a+b+10)

Do i need to use any class?