两个re是为什么呀
查看原帖
两个re是为什么呀
874765
852810242_121楼主2023/4/28 21:48
#include"iostream"
using namespace std;
const int N = 1024;
bool a[N][N] = {false};
int n, m, k;
int ans;
int huoba(int x, int y);
int yingshi(int x, int y);
int main()
{
	cin >> n >> m >> k;
	for (int i = 1; i <= m; i++)
	{
		int x, y;
		cin >> x >> y;
		huoba(x, y);
	}
	for (int i = 1; i <= k; i++)
	{
		int x, y;
		cin >> x >> y;
		yingshi(x, y);
	}

	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			if (a[i][j] == false)
				ans++;
		}
	}
	cout << ans;
	return 0;
}

int huoba(int x, int y)
{
	for (int i = x - 2; i <= x + 2; i++)//横向
	{
		a[i][y] = true;
	}
	for (int j = y - 2; j <= y + 2; j++)//纵向
	{
		a[x][j] = true;
	}
	a[x - 1][y - 1] = a[x - 1][y + 1] = true;
	a[x + 1][y - 1] = a[x + 1][y + 1] = true;
	return 0;
}
int yingshi(int x, int y)
{
	for (int i = x - 2; i <= x + 2; i++)
	{
		for (int j = y - 2; j <= y + 2; j++)
		{
			a[i][j] = true;
		}
	}
	return 0;
}
2023/4/28 21:48
加载中...