2.1.16 —线性表—Rotate Image
来源:互联网 发布:英雄杀这次探宝数据 编辑:程序博客网 时间:2024/06/05 03:24
描述
You are given an n × n2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
You are given an n × n2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
Follow up: Could you do this in-place?
#include<iostream>#include<vector>using namespace std;const int n = 4;void RotataImage(int a[][n], int m){for (int i = 0; i < m; i++){for (int j = 0; j < n - i - 1; j++){int temp = a[i][j];a[i][j] = a[n - j - 1][n - i - 1];a[n - j - 1][n - i - 1] = temp;}}for (int i = 0; i < m / 2; i++){for (int j = 0; j < n; j++){int temp = a[i][j];a[i][j] = a[n - i - 1][j];a[n - i - 1][j] = temp;}}}int main(){int a[n][n] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };RotataImage(a, n);for (int i = 0; i < n; i++){for (int j = 0; j < n; j++)cout << a[i][j] << " ";cout << endl;}}
阅读全文
0 0
- 2.1.16 —线性表—Rotate Image
- 2.1.16 Rotate Image
- LeetCode 2.1.16 Rotate Image
- LeetCode——Rotate Image
- LeetCode——Rotate Image
- LeetCode——Rotate Image
- leetcode——Rotate Image
- LeetCode48——Rotate Image
- 数组——rotate-image
- Algorithms—48.Rotate Image
- leetcode 048 —— Rotate Image
- LeetCode OJ——Rotate Image
- LeetCode题解——Rotate Image
- Leetcode题集——rotate image
- Leetcode——48. Rotate Image
- 16: Rotate Image
- leetcode——48——Rotate Image
- 【leetcode】Array——Rotate Image(48)
- 【Java】WebMagic实现的最基本的爬虫
- appium自动化测试
- css3 checkbox动画
- R语言地图可视化
- 新手学C++多线程编程(4)多任务与多线程编程
- 2.1.16 —线性表—Rotate Image
- 【几何】hdu 6055 Regular polygon
- android 启动时出现空白带标题的页面解决办法
- 关于APP广告也面图片的保存问题
- 百练noi21:二维数组右上左下遍历,24:蛇形填充数组
- 2017 Multi-University Training Contest 3( hdu 6060) RXD and dividing
- spring-batch示例配置文件
- Android 5.0 Camera系统源码分析(4):Camera预览流程数据流
- ARKit从入门到精通(2)-ARKit工作原理及流程介绍