首页 > 其他 > 详细

Rotate Image

时间:2015-06-19 02:08:28      阅读:114      评论:0      收藏:0      [点我收藏+]

public class Solution {

? ? public void rotate(int[][] matrix) {

? ? ? ? int n = matrix.length-1;

? ? ? ? for (int i = 0; i <= n; i++) {

? ? ? ? for (int j = i+1; j <= n-i; j++) {

? ? ? ? int n1 = matrix[i][j];

? ? ? ? ? ? ? ? int n2 = matrix[j][n-i];

? ? ? ? ? ? ? ? int n3 = matrix[n-i][n-j];

? ? ? ? ? ? ? ? int n4 = matrix[n-j][i];

? ? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? matrix[i][j] = n4;

? ? ? ? ? ? ? ? matrix[j][n-i] = n1;

? ? ? ? ? ? ? ? matrix[n-i][n-j] = n2;

? ? ? ? ? ? ? ? matrix[n-j][i] = n3;

? ? ? ? }

? ? ? ? }

? ? }

}

Rotate Image

原文:http://hcx2013.iteye.com/blog/2220731

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!