60分求助
查看原帖
60分求助
666278
liangkw01楼主2023/7/14 17:08
#include<bits/stdc++.h>
using namespace std;

int n,m,k,x,y;
char color,dire,a[55][55];

int main() {
	cin >> n >> m >> k;
	for (int i = 1;i <= k;i++) {
		cin >> x >> y >> color >> dire;
		if (dire == 'U') {
			for (int j = x;j >= 1;j--) {
				a[j][y] = color;
			}
		} else if (dire == 'D') {
			for (int j = x;j <= n;j++) {
				a[j][y] = color;
			}
		} else if (dire == 'L') {
			for (int j = y;j >= 1;j--) {
				a[x][j] = color;
			}
		} else if (dire == 'R') {
			for (int j = y;j <= n;j++) {
				a[x][j] = color;
			}
		}
	}
	for (int i = 1;i <= n;i++) {
		for (int j = 1;j <= m;j++) {
			if (a[i][j] >= 'a' && a[i][j] <= 'z') cout << a[i][j];
			else cout << '.';
		}
		cout << endl;
	}
	return 0;
}

2023/7/14 17:08
加载中...