6 rotate-image
来源:互联网 发布:java 文件存在判断 编辑:程序博客网 时间:2024/05/21 20:24
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?
图像顺时针90度旋转
1.找规律:发现 可以将 matrix[i][j]=maxtrix[n-1-j][i]
先写了一个本办法,有用了一个矩阵
public class Solution {
public void rotate(int[][] matrix) {
int n =matrix.length;
int[][] b =new int[n][n];
for(int i=0;i<=n-1;i++)
{
for(int j=0;j<=n-1;j++)
{
b[i][j]=matrix[n-1-j][i];
}
}
for(int i=0;i<=n-1;i++)
{
for(int j=0;j<=n-1;j++)
{
matrix[i][j]=b[i][j];
}
}
}
}
0 0
- 6 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
- iOS之SDWebimage下载图片链接带中文处理
- C++ STL 文件读取和容器(转载自http://blog.sina.com.cn/s/blog_735f29100102uwwd.html)
- 股票数据自动入库hive到oracle
- android 更换时区时间同步
- 原型模式(Prototype)
- 6 rotate-image
- 独显和集显设置,双显卡工作及cuda计算
- spring定时任务配置、使用说明(简单、全)
- Android之RecyclerView的使用总结
- ECMAScript 6
- 几个ip查询接口
- mysql 插入数据是主键或唯一值重复的解决方法
- ArrayList的使用方法【转载】
- 压力测试工具JMeter入门教程