java the ranks of two-dimensional array of swap

java the ranks of two-dimensional array of swap

 

public class Test {
    public static void main(String[] args) {
        int arr[][] = new int[][] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };
        System.out.println ( "Top notes intermodulation ranks:" );
         // output two-dimensional array 
        printArray (ARR);
         int arr2 is [] [] = new new  int [arr.length] [arr.length];
         for ( int I 0 =; I <arr.length; I ++) { // adjust array row data 
            for ( int J = 0; J <ARR [I] .length; J ++ ) {
                arr2[i][j] = arr[j][i];
            }
        }
        System.out.println ( "After the ranks of intermodulation:" );
         // output ranks each other after the transfer of two-dimensional array 
        printArray (arr2);
    }

    /**
     * All the elements through the array and output array
     */
    private static void printArray(int[][] arr) {
        for (int i = 0; i < arr.length; i++) {// 遍历数组
            for (int j = 0; j < arr.length; j++) {
                Of System.out.print (ARR [I] [J] + ""); // not wrap array element outputs 
            }
            System.out.println ();     // wrap 
        }
    }
}

 

Guess you like

Origin www.cnblogs.com/ComputerVip/p/12028524.html