I 棋盘

#include<iostream>
#include<cstdio>
using namespace std;

char MAP[20][20];

int main()
{
	for(int i = 1; i <= 9; i++)
	{
		for(int j = 1; j <= 9; j++)
		{
			cin >> MAP[i][j];
		}
	}
	int x, y;
	cin >> x >> y;
	if(x % 3 == 0)
		x = 9;
	else
		x = x % 3 * 3;
	if(y % 3 == 0)
		y = 9;
	else
		y = y % 3 * 3;
	bool flag = false;
	for(int i = x - 2; i <= x; i++)
	{
		for(int j = y - 2; j <= y; j++)
		{
			if(MAP[i][j] == '.')
			{
				MAP[i][j] = '!';
				flag = true;
			}
		}
	}
	if(flag == false)
	{
		for(int i = 1; i <= 9; i++)
		{
			for(int j = 1; j <= 9; j++)
			{
				if(MAP[i][j] == '.')
					cout << "!";
				else
					cout << MAP[i][j];
				if(j % 3 == 0 && j != 9)
					cout << " ";
			}
			cout << endl;
			if(i % 3 == 0 && i != 9)
				cout << endl;
		}
	}
	else
	{
		for(int i = 1; i <= 9; i++)
		{
			for(int j = 1; j <= 9; j++)
			{
				cout << MAP[i][j];
				if(j % 3 == 0 && j != 9)
					cout << " ";
			}
			cout << endl;
			if(i % 3 == 0 && i != 9)
				cout << endl;
		}
	}
	return 0;
}

千辛万苦

猜你喜欢

转载自blog.csdn.net/someone_and_anyone/article/details/79848500
I