rotate-image 1.0.0
Rotate Image
Loading...
Searching...
No Matches
Solution Class Reference

Public Member Functions

void print (vector< vector< int > > &matrix)
 
void rotate (vector< vector< int > > &matrix)
 

Private Member Functions

void transpose (vector< vector< int > > &matrix)
 
void vertical_reflection (vector< vector< int > > &matrix)
 

Detailed Description

Definition at line 5 of file main.cpp.

Member Function Documentation

◆ print()

void Solution::print ( vector< vector< int > > &  matrix)
inline

Definition at line 36 of file main.cpp.

37 {
38 for (vector<int>& row: matrix)
39 {
40 for (int el: row)
41 cout << el << " ";
42 cout << endl;
43 }
44 }

Referenced by main().

◆ rotate()

void Solution::rotate ( vector< vector< int > > &  matrix)
inline

Definition at line 46 of file main.cpp.

47 {
48 transpose(matrix);
49 vertical_reflection(matrix);
50 }
void transpose(vector< vector< int > > &matrix)
Definition main.cpp:8
void vertical_reflection(vector< vector< int > > &matrix)
Definition main.cpp:21

References transpose(), and vertical_reflection().

Referenced by main().

◆ transpose()

void Solution::transpose ( vector< vector< int > > &  matrix)
inlineprivate

Definition at line 8 of file main.cpp.

9 {
10 for (int i = 0; i < (int)matrix.size(); ++i)
11 {
12 for (int j = i + 1; j < (int)matrix.size(); ++j)
13 {
14 int tmp = matrix[i][j];
15 matrix[i][j] = matrix[j][i];
16 matrix[j][i] = tmp;
17 }
18 }
19 }

Referenced by rotate().

◆ vertical_reflection()

void Solution::vertical_reflection ( vector< vector< int > > &  matrix)
inlineprivate

Definition at line 21 of file main.cpp.

22 {
23 int n = (int)matrix.size();
24 for (int i = 0; i < n; ++i)
25 {
26 for (int j = 0; j < n / 2; ++j)
27 {
28 int tmp = matrix[i][j];
29 matrix[i][j] = matrix[i][n - 1 - j];
30 matrix[i][n - 1 - j] = tmp;
31 }
32 }
33 }

Referenced by rotate().


The documentation for this class was generated from the following file: