首页 > 其他 > 详细

Rotate Image

时间:2015-06-14 10:52:20      阅读:183      评论:0      收藏:0      [点我收藏+]

Description:

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?

 

Code:

 1     void rotate(vector<vector<int>>& matrix) {
 2         int n = matrix.size();
 3         vector< vector<int> > temp(matrix);
 4         for (int i = 0; i < n; ++i)
 5         {
 6             for (int j = 0; j < n; ++j)
 7             {
 8                 matrix[i][j] = temp[n-1-j][i];
 9             }
10         }
11     }

 

Rotate Image

原文:http://www.cnblogs.com/happygirl-zjj/p/4574627.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!