1 //Transpose a Matrix
2
3 for (int row = 0; row < matrix.length; row++) {
4
5 for (int col = row; row < matrix[row].length; col++)
6 {
7 // Swap
8 int data = matrix[row][col];
9 matrix[row][col] = matrix[col][row];
10 matrix[col][row] = data;
11 }
12
13 }