博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
48. Rotate Image
阅读量:4647 次
发布时间:2019-06-09

本文共 658 字,大约阅读时间需要 2 分钟。

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?

void rotate(vector
>& matrix) { int n = matrix.size(), i, j, k, t, x, y, tx; for(i = 0; i <= n>>1; i++) { for(j = i; j < n-1-i; j++) { t = matrix[i][j]; x = i; y = j; for(k = 0; k < 3; k++) { matrix[x][y] = matrix[n-1-y][x]; tx = x; x = n-1-y; y = tx; } matrix[x][y] = t; } }}

 

转载于:https://www.cnblogs.com/argenbarbie/p/5264757.html

你可能感兴趣的文章
父类引用指向子类对象
查看>>
网页如何实现下载功能
查看>>
IT男专用表白程序
查看>>
读《大道至简》第六章感想
查看>>
ef linq 中判断实体中是否包含某集合
查看>>
章三 链表
查看>>
Solution for Concurrent number of AOS' for this application exceeds the licensed number
查看>>
CSE 3100 Systems Programming
查看>>
IntelliJ IDEA 的Project structure说明
查看>>
Java Security(JCE基本概念)
查看>>
Linux Supervisor的安装与使用入门
查看>>
创建 PSO
查看>>
JasperReport报表设计4
查看>>
项目活动定义 概述
查看>>
团队冲刺04
查看>>
我的Python分析成长之路8
查看>>
泛型在三层中的应用
查看>>
SharePoint2010 -- 管理配置文件同步
查看>>
.Net MVC3中取得当前区域的名字(Area name)
查看>>
获得屏幕像素以及像素密度
查看>>