1
我对这段代码有困难。我试图返回一个2d,这是输入数组的反转。 我不知道如何正确编码。也许有人可能会有几点建议通过二维数组循环
public class arrays {
int[][] transpose(int[][] a) {
int[][] good = new int[a.length][a.length]; /* assign dimension, I want it to be the same as input */
for (int i = 0; i < a.length; i++) {
for (int k = 0; k < a[k].length; k++) { // //nested loop to go through the rows and columns
good[i][k] = a[k][i]; // /// switch elements
}
}
return good;
}
}
谢谢!非常有帮助 – tim