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

48 Rotate Image

时间:2015-05-23 06:29:05      阅读:108      评论:0      收藏:0      [点我收藏+]

标签:

public class Solution {
    public void rotate(int[][] matrix) {
        if (matrix == null || matrix.length == 0) {
            return;
        }
        int len = matrix.length;
        for (int i = 0; i < len/2; i++) {
            for (int j = 0; j < (len + 1)/2; j++) {
                int tmp = matrix[i][j];
                matrix[i][j] = matrix[len - j - 1][i];
                matrix[len - j - 1][i] = matrix[len - i - 1][len - j - 1];
                matrix[len - i - 1][len - j - 1] = matrix[j][len - i - 1];
                matrix[j][len - i - 1] =tmp;
            }
        }
    }
}

 

48 Rotate Image

标签:

原文地址:http://www.cnblogs.com/77rousongpai/p/4523633.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!