-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbaekjoon16926.cpp
54 lines (43 loc) · 914 Bytes
/
baekjoon16926.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
#include <iostream>
#include <cmath>
using namespace std;
int n, m, r;
int arr[301][301];
void rotation(int x, int y) {
int count = min(x, y) / 2;
for (int c = 0; c < count; c++) {
int xMax = x - c - 1;
int yMax = y - c - 1;
int start = arr[c][c];
for (int j = c; j < yMax; j++) { // 0 ~ x-1±îÁö
arr[c][j] = arr[c][j + 1]; // 0, j <- 0, j+1
}
for (int i = c; i < xMax; i++) { //
arr[i][yMax] = arr[i+1][yMax]; //
}
for (int j = yMax; j > c; j--) {
arr[xMax][j] = arr[xMax][j-1];
}
for (int i = xMax; i > c; i--) {
arr[i][c] = arr[i-1][c];
}
arr[c + 1][c] = start;
}
}
int main() {
cin >> n >> m >> r;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> arr[i][j];
}
}
for (int i = 0; i < r; i++) {
rotation(n, m);
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << arr[i][j] << " ";
}
cout << "\n";
}
}