import java.util.Date;
import java.util.Random;

public class Main {

    public static void main(String[] args) {
        final int n = 8;
        final int m = 5;
        int[][] matrix = new int[n][m];

        Random rand = new Random(new Date().getTime());
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                    int value = rand.nextInt(200);
                    matrix[i][j] = value;
            }
        }

        System.out.println("Original matrix");
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                    System.out.print(matrix[i][j] + " ");
            }
            System.out.println();
        }

        int[][] matrix2 = Transpose(matrix,n,m);
        System.out.println();
        System.out.println("Transpose matrix");
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                    System.out.print(matrix2[i][j] + " ");

            }
            System.out.println();
        }

        int[][] matrix3 = Transpose(matrix2,m,n);
        System.out.println();
        System.out.println("Double-transpose matrix");
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                System.out.print(matrix3[i][j] + " ");

            }
            System.out.println();
        }

    }

    public static int[][] Transpose(int[][] matrix, int n, int m) {
        int[][] newmatrix = new int[m][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                newmatrix[j][i] = matrix[i][j];
            }
        }
            return newmatrix;
    }
}

@@ -351,20 +351,16 @@
         
-    
 int valu
@@ -382,20 +382,16 @@
 t(200);%0A
-    
         
@@ -564,36 +564,32 @@
 ; j %3C m; j++) %7B%0A
-    
                 
@@ -622,24 +622,24 @@
 %5Bj%5D + %22 %22);%0A
+
             
@@ -728,18 +728,20 @@
 (matrix,
+ 
 n,
+ 
 m);%0A    
@@ -886,36 +886,32 @@
 ; j %3C n; j++) %7B%0A
-    
                 
@@ -941,32 +941,32 @@
 2%5Bi%5D%5Bj%5D + %22 %22);%0A
+
 %0A            %7D%0A 
@@ -1057,10 +1057,12 @@
 ix2,
+ 
 m,
+ 
 n);%0A
@@ -1603,36 +1603,32 @@
     %7D%0A        %7D%0A
-    
         return n

Transpose matrix