/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
/* 8.Задане двомірне поле, що містить замкнені чорні і червоні НЕ зафарбовані області на
білому тлі.Визначити, чи знаходиться хоча б одна червона область всередині чорної.
Допускається замінити колір на кодове представлення. */
#include <iostream>
using namespace std;
int seachpos(int);
int main()
{
int const N = 4;
int const M = 5;
int arr[N][M] =
{
{0, 1, 1, 0, 1},
{1, 1, 1, 1, 1},
{0, 1, 0, 1, 0},
{1, 1, 1, 1, 1}
};
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++)
{
cout << arr[i][j] << " ";
}
cout << endl;
}
}
int seachpos(int N, int M, int arr[N][M])
{
return i >= 0 && j >= 0 && i < NROW&& j < NCOL;
for (int di = -1; di <= 1; di++) {
for (int dj = -1; dj <= 1; dj++)
{
if (di == 0 && dj == 0) continue;
int ni = i + di, nj = j + dj;
if (ni, nj) && m[ni][nj] == 0)
return false;
}
}
return true;
if (m[i][j] == 0 && (i, j)) {
cout << "[" << i << ", " << j << "]" << endl;
}
}