java multi-dimensional array transposing

后端 未结 11 2172
谎友^
谎友^ 2020-12-10 11:42

I have a row-based multidimensional array:

/** [row][column]. */
public int[][] tiles;

I would like to transform this array to column-based

11条回答
  •  天命终不由人
    2020-12-10 12:17

    If you want to go for in place transpose of a matrix(in which case row count = col count) you can so following in Java

    public static void inPlaceTranspose(int [][] matrix){
    
        int rows = matrix.length;
        int cols = matrix[0].length;
    
        for(int i=0;i

提交回复
热议问题