Rotate Image 二维数组旋转90度
来源:互联网 发布:万网域名赎回费用 编辑:程序博客网 时间:2024/05/14 13:08
Rotate Image
You are given an n x n 2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
Follow up:
Could you do this in-place?
class Solution {public: void rotate(vector<vector<int> > &matrix) { //方法1:tempMatrix[j][n-1-i] = matrix[i][j]; 置换 //方法2:先对角线翻转,再中间线上下翻转 int n,i,j,temp; n=matrix.size(); for(i=0;i<n;i++) { for(j=0;j<n-i;j++) { temp=matrix[i][j]; matrix[i][j]=matrix[n-1-j][n-1-i]; matrix[n-1-j][n-1-i]=temp; } } for(i=0;i<n/2;i++) { for(j=0;j<n;j++) { temp=matrix[i][j]; matrix[i][j]=matrix[n-1-i][j]; matrix[n-1-i][j]=temp; } } }};
0 0
- Rotate Image 二维数组旋转90度
- Rotate Image 数组顺时针旋转90度
- LeetCode——Rotate Image(二维数组顺时针旋转90度)
- LeetCode-----48. Rotate Image(二维矩阵旋转90度)
- Rotate Image(二位数组顺时针旋转)
- java算法之简单的二维矩阵旋转Rotate Image
- 二维数组旋转90度
- 二维数组旋转90度
- 旋转二维数组90度
- Rotate Image 矩阵旋转90度,没有额外空间
- 方形矩阵顺时针旋转90度 Rotate Image
- 将矩阵顺时针旋转90度 leetCode:Rotate Image
- [leetcode 48] Rotate Image--------矩阵旋转90度
- LeetCode-48-Rotate Image 矩阵旋转90
- Rotate Image 旋转图像
- 【旋转矩阵】Rotate Image
- 二维数组旋转90度输出
- python 二维数组90度旋转
- php调试工具---xhprof安装和使用
- [置顶] 最常用的15大Eclipse开发快捷键技巧
- spring容器启动之我见(二)
- Linux下修改终端提示符
- iOS开发 Coretext(文字排版)的基本用法
- Rotate Image 二维数组旋转90度
- 深度学习原理和实践
- 算法面试——二叉树最低公共祖先LCA
- 多线程和多进程的区别(小结)
- Anagrams 寻找相同的乱序的字母排列
- Python 关于 name main的使用 if __name__ == '__main__':
- 显示遮罩层并从屏幕上方滑出div
- oracle数据库导入与导出
- 【安全健行】(一):Hacker编程技能