【发布时间】:2016-09-11 10:39:57
【问题描述】:
我大约 2 周前开始学习 Java,所以请不要评判。 我正在用一个二维数组(一张图片)做这个程序,我想旋转 90 度(已经完成,测试,它可以工作)和 180 度。我的方法是无效的,我想使用 90 度一个两次(作曲?)在 180 度一次,但它不起作用。
这是我的90方法:
public void rotate90(){
for (int r = 0; r < w; r++) {
for (int c = 0; c < h; c++) {
imageMatrix[c][w-r-1] = imageMatrix[r][c];
}
}
public void rotate180(){
rotate90(rotate90()); // my idea was to rotate again the already rotated matrix, but since rotate90 is void it doesn't work
}
有什么办法可以做到这一点吗?使用 void 函数?
提前致谢!
【问题讨论】:
标签: java arrays for-loop matrix void