C++ mine filed idea


#1
void mark(vector<string> &A, int x, int y)
{
	if (x<0 || y<0 || x>A.size() - 1 || y>A[x].size() - 1)
		return;
	if (A[x][y] != 'X')
		return;
	A[x][y] = 'O';
	mark(A, x - 1, y);
	mark(A, x + 1, y);
	mark(A, x, y - 1);
	mark(A, x, y + 1);
}
int Solution::black(vector<string> &A) {
    int count = 0;
	for (int i = 0; i < A.size(); i++)
	{
		for (int j = 0; j < A[i].size(); j++)
		{
			if (A[i][j] != 'O')
			{
				count++;
				mark(A, i, j);
			}
		}
	}
	return count;
}