洛谷_P6368 [COCI2006-2007#6] MAGIJA(尚贤)

题目传送门

照着模拟就行

AC代码

#include <iostream>
#include <cstdio>
#include <string>
#define SIZE (int)50 + 10
using namespace std;
string map[SIZE];

string fan(string);

int main() {
	freopen("cpp.in", "r", stdin);
	freopen("cpp.out", "w", stdout);
	int n, m, x, y;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; ++i) {
		cin >> map[i];
		map[i] += fan(map[i]);
	}
	scanf("%d%d", &x, &y);
	--x, --y;
	for (int i = n, j = 1; i < n * 2; ++i, ++j, ++j) {
		map[i] += map[i - j];
	}
	map[x][y] = (map[x][y] == '.') ? '#' : '.';
	for (int i = 0; i < n * 2; ++i) {
		cout << map[i] << endl;
	}
	return 0;
}

string fan(string str) {
	for (int i = 0; i < str.size() / 2; ++i) {
		swap(str[i], str[str.size() - i - 1]);
	}
	return str;
}
发布了33 篇原创文章 · 获赞 0 · 访问量 167

猜你喜欢

转载自blog.csdn.net/weixin_42790071/article/details/105542813