给定一个NxN的矩阵,将图像顺时针旋转90度。

像素翻转

http://www.nowcoder.com/questionTerminal/17ab1e527c504df09a600e1af09d9a60

public int[][] transformImage(int[][] mat, int n) {
        // write code here
        int[][] result = new int[n][n];
        int[] tmp = new int[n];
        for (int i=0;i<n;i++){
            for (int j=0;j<n;j++) {
                tmp[j] = mat[n-j-1][i];
            }
            result[i] = tmp;
            tmp = new int[n];
        }
        return result;
    }

全部评论
这空间浪费有点严重啊
点赞 回复 分享
发布于 2021-02-07 15:35

相关推荐

评论
点赞
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务