matrix[i][j]需要放在转置矩阵的(j,i)位置
public class Solution {public int[][] Transpose(int[][] matrix) {int rows = matrix.Length; int columns = matrix[0].Length; int[][] array2 = new int[columns][];// 初始化内部数组(列数)for (int i = 0; i < array2.Length; i++){array2[i] = new int[rows]; // 每行rows个元素}for(int i=0;i<rows;i++){for(int j=0;j<columns;j++){array2[j][i]=matrix[i][j];}}return array2;}
}