首页 > 其他 > 详细

Jan 17 - Rotate Image; 2D Array; xPos and yPos;

时间:2016-01-18 13:49:07      阅读:132      评论:0      收藏:0      [点我收藏+]

代码:

public class Solution {
    public void rotate(int[][] matrix) {
        int n = matrix.length;
        for(int i = 0; i < n/2; i++){
            int num = n-i*2;
            for(int j = 0; j < num-1; j++){
                int temp = matrix[i][i+j];
                matrix[i][i+j] = matrix[i+num-1-j][i];
                matrix[i+num-1-j][i] = matrix[i+num-1][i+num-1-j];
                matrix[i+num-1][i+num-1-j] = matrix[i+j][i+num-1];
                matrix[i+j][i+num-1] = temp;
            }
        }
    }
}

  

Jan 17 - Rotate Image; 2D Array; xPos and yPos;

原文:http://www.cnblogs.com/5683yue/p/5138932.html

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