-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1023.cpp
74 lines (70 loc) · 1.52 KB
/
1023.cpp
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <iostream>
using namespace std;
void getresult(int method,int length,int matrix[700][700])
{
if(method==0)
{
int tmp;
for(int i=1;i<=length;++i)
{
for(int j=1;j<=(length/2);++j)
{
tmp = matrix[i][j];
matrix[i][j] = matrix[i][length-j+1];
matrix[i][length-j+1] = tmp;
}
}
}
else if(method ==1)
{
int tmp;
for(int i=1;i<=length;++i)
{
for(int j=1;j<=(length/2);++j)
{
tmp = matrix[j][i];
matrix[j][i] = matrix[length-j+1][i];
matrix[length-j+1][i] = tmp;
}
}
}
}
int main()
{
int matrix[700][700];
int n,method,length;
cin>>n;
for(int i=1;i<=n;++i)
{
cin>>length>>method;
for(int j=1;j<=length;++j)
{
for(int k=1;k<=length;++k)
{
cin>>matrix[j][k];
}
}
if(method==2)
{
for(int j=1;j<=length;++j)
{
for(int k=1;k<=length;++k)
{
cout<<matrix[k][j]<<' ';
}
cout<<endl;
}
continue;
}
getresult(method,length,matrix);
for(int j=1;j<=length;++j)
{
for(int k=1;k<=length;++k)
{
cout<<matrix[j][k]<<' ';
}
cout<<endl;
}
}
return 0;
}