Rotate Image
来源:互联网 发布:java事务处理机制 编辑:程序博客网 时间:2024/06/06 16:32
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?
这个for循环中的下标非常容易搞混,一定要区分清楚,到底固定哪一列,对于第二个for里面,i相当于常量,要区分清楚是行变还是列变
并不是i代表行,j代表列
Rotate the image by 90 degrees (clockwise).
Follow up:
Could you do this in-place?
这个for循环中的下标非常容易搞混,一定要区分清楚,到底固定哪一列,对于第二个for里面,i相当于常量,要区分清楚是行变还是列变
并不是i代表行,j代表列
void rotate(vector<vector<int> > &matrix) {int size = matrix.size();if (size < 2) return;for (int i = 0; i < size/2; i++){for (int j = i; j < size-i-1; j++){int temp = matrix[i][j];matrix[i][j] = matrix[size-j-1][i];matrix[size-j-1][i] = matrix[size-i-1][size-j-1];matrix[size-i-1][size-j-1] = matrix[j][size-i-1];matrix[j][size-i-1] = temp;}} }
0 0
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Two Sum-----LeetCode
- Visual Studio 2012旗舰版序列号:
- 1024. Palindromic Number
- Cocos2d-x 3.0 开发(十七)使用Cocos2d-x 3.0rc,一条命令打包Android
- win8.1 64位系统下正确安装串口转usb驱动
- Rotate Image
- 日期与时间处理
- .net开发框架
- 《Pyhon简明教程》学习摘要
- 使窗口在整个屏幕居中
- Ubuntu安装OMNet++4.2.2
- Dahua Lin是香港中文大学汤晓鸥教授的高徒,在计算机视觉/机器学习方面有很深的造诣。他在自己的主页上有一个推荐书表,值得大家作为参考。 全英文版的,感觉到与国际接轨的压力了!!!
- SQL语句的解析过程
- zoj 3203 Light Bulb(几何求距离)