-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathach3.cpp
More file actions
38 lines (37 loc) · 671 Bytes
/
Copy pathach3.cpp
File metadata and controls
38 lines (37 loc) · 671 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include<bits/stdc++.h>
using namespace std;
void rotate(vector<vector<int>>& mat,int n)
{
for(int i=0;i<n;i++)
{
for(int j=0;j<i;j++)
{
swap(mat[i][j],mat[j][i]);
}
}
for(int i=0;i<n;i++)
{
for(int j=0;j<n/2;j++)
{
swap(mat[i][j],mat[i][n-j-1]);
}
}
}
int main()
{
int n;
cin>>n;
vector<vector<int>> mat(n,vector<int> (n));
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
cin>>mat[i][j];
}
rotate(mat,n);
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
cout<<mat[i][j]<<" ";
cout<<endl;
}
}