Files
python/TangDou/LuoGuBook/第8章模拟与高精度/P4924.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

42 lines
1.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
const int N = 510;
int n, m;
int x, y, r, z;
int tmp[N][N], res[N][N];
int cnt;
// 数组res为最后输出的结果数组,tmp为辅助数组;
int main() {
cin >> n >> m;
//初始化数据
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
res[i][j] = tmp[i][j] = ++cnt;
//读入魔法指令
while (m--) { // m次指令
cin >> x >> y >> r >> z;
//处理旋转
if (z == 0) { //顺时针
for (int i = -r; i <= r; i++)
for (int j = -r; j <= r; j++)
tmp[x + j][y - i] = res[x + i][y + j];
} else if (z == 1) { //逆时针
for (int i = -r; i <= r; i++)
for (int j = -r; j <= r; j++)
tmp[x - j][y + i] = res[x + i][y + j];
}
//复制回来
memcpy(res, tmp, sizeof tmp);
}
//输出
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++)
printf("%2d ", res[i][j]);
printf("\n");
}
return 0;
}