forked from akshitagupta15june/100code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrotate_image.cpp
More file actions
54 lines (54 loc) · 864 Bytes
/
Copy pathrotate_image.cpp
File metadata and controls
54 lines (54 loc) · 864 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include<algorithm>
using namespace std;
void rotate_image(int a[][1000],int n)
{
for(int i=0;i<n;i++)
{
int sc=0;
int ec=n-1;
while(sc<ec)
{
swap(a[i][sc],a[i][ec]);
sc++;
ec--;
}
}
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(i<j)
{
swap(a[i][j],a[j][i]);
}
}
}
}
void display(int a[][1000],int n)
{
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
cout<<a[i][j]<<" ";
}
cout<<endl;
}
}
int main()
{
int a[1000][1000];
int n;
cin>>n;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
cin>>a[i][j];
}
}
rotate_image(a,n);
display(a,n);
return 0;
}