码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-01-18 13:50:51      阅读:154      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!