10pts求调
查看原帖
10pts求调
1242208
wyp20130701_是一个蒟蒻楼主2025/8/4 13:32
#include<iostream>
using namespace std;
int a[505][505], c[505][505];
int main(){
	int n, m; cin >> n >> m;
	int cnt = 0, _ = 1;
	for (int i = 1; i <= n * n; i++){
		if (cnt == n){
			_++;
			cnt = 0;
		}
		cnt++;
		a[_][cnt] = i;
	}
	for (int i = 1; i <= m; i++){
		int x, y, r, z;
		cin >> x >> y >> r >> z;
		int x1 = x - r, y1 = y - r;
		int x2 = x + r, y2 = y + r;
		if (z == 1){
			for (int i = x1, i1 = x1; i <= x2; i++, i1++)
				for (int j = y1, j1 = y2; j <= y2; j++, j1--)
					c[j1][i1] = a[i][j];
			for (int i = x1; i <= x2; i++)
				for (int j = y1; j <= y2; j++)
					a[i][j] = c[i][j];
		}
		if (z == 0){
			for (int i = x1, i1 = x2; i <= x2; i++, i1--)
				for (int j = y1, j1 = y1; j <= y2; j++, j1++)
					c[j1][i1] = a[i][j];
			for (int i = x1; i <= x2; i++)
				for (int j = y1; j <= y2; j++)
					a[i][j] = c[i][j];
		}
	}
	for (int i = 1; i <= n; i++, cout << endl)
		for (int j = 1; j <= n; j++)
			cout << a[i][j] << ' ';
	return 0;
} 

在线等,急!

2025/8/4 13:32
加载中...