So I’m working on a project where I need to find the largest contiguous region of a 2D array that has the same element. So far I’ve tried to use two for loops but haven’t been able to get the results I want. Any help would be greatly appreciated.
Here’s the code I’ve tried so far:
for (int i = 0; i < 15; i++)
{
for (int j = 0; j < 15; j++)
{
if (pixelArray[i][j].color == Blue)
{
conBlue++;
if (pixelArray[i++][j].color != Blue && pixelArray[i][j++].color != Blue && pixelArray[i][j--].color != Blue && pixelArray[i--][j].color != Blue)
{
conBlue = 0;
}
if (conBlue > totalConBlue)
{
totalConBlue = conBlue;
}
}
}
}
Source: Windows Questions C++