【发布时间】:2014-05-23 14:35:57
【问题描述】:
我正在尝试转换二维数组。水平行的内容被转移到垂直列。
public static void change(short image[])
{
int arrayLength = 29; // row length
int arrayWidth = 10; // column length
// array with values
short[][] decompressedImage = new short[arrayLength][arrayWidth];
// array to store transposed image
short[][] transposedImage = new short[arrayWidth][arrayLength];
// store transposed values
for (int i=0;i<arrayWidth; i++){
for (int j=0;j<arrayLength; j++){
transposedImage[j][i]=decompressedImage[i][j];
}
}
}
【问题讨论】:
-
你的意思是要旋转数组?
-
是的,旋转它! -90度
-
decompressedImage 或 transposedImage 的 arrayLength & arrayWidth 维度是??
-
@ray,我可以在网上找到这些东西,但我正在尝试解决我的代码片段中的问题。
标签: java for-loop matrix multidimensional-array