rotate-image
来源:互联网 发布:硬盘修复软件 编辑:程序博客网 时间:2024/06/06 07:11
题目:
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) { if (matrix.size() == 0) return ; if (matrix[0].size() == 0) return; int m = matrix.size(); int n = matrix[0].size(); if (m != n) return; for (int i = 0; i < m; i++) { for (int j = i+1; j < n; j++) { swap(matrix[i][j], matrix[j][i]); } } for (int i = 0; i < m; i++) { for (int j = 0; j < n/2; j++) { swap(matrix[i][j], matrix[i][n-1-j]); } } }};
阅读全文
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
- CodeMirror 的简单配置
- bzoj1468 Tree 点分治
- CentOS 7 下安装mosquitto
- Nginx常用集群以及解决TomcatSession问题
- keil工程无法调试
- rotate-image
- AngularJS 学习笔记(4)-过滤器,$location
- ArcEngine创建要素类_线图层
- 项目1-C++语言中函数参数传递的三种方式
- 算法提高 ADV-135 三角形面积
- IE8、7、6动态添加样式时,CSS hack的BUG
- MySQL单表查询多表查询
- 对于loader constraint violation问题的解决方案
- luogu1262 间谍网络(tarjan缩点)