#include<iostream>
#include<vector>
using namespace std;
int counter = 0;
int x = 1, y = 1;
vector<int> number;
bool flood_fill[10][10] = { 0 };
void calculator(int x, int y);
void alpha()
{
if (counter)
{
number.push_back(counter);
}
counter = 0;
calculator(x, y);
if (x == 8&&y==8)
{
return;
}
else if (y < 8)
{
y++;
}
else
{
x++;
y = 1;
}
alpha();
}
void calculator(int x,int y)
{
if (flood_fill[x][y])
{
flood_fill[x][y] = false;
counter++;
calculator(x + 1, y);
calculator(x - 1, y);
calculator(x, y + 1);
calculator(x, y - 1);
}
}
int main()
{
for (int i = 1; i < 9; i++)
{
for (int j = 1; j < 9; j++)
{
if (rand() % 2 == 0)
{
flood_fill[i][j] = true;
}
}
}
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 10; j++)
{
if (flood_fill[i][j])
{
cout << 'w' << " ";
}
else
{
cout << 'b' << " ";
}
}
cout << endl;
}
alpha();
cout << number.size() << "white area of ";
for (vector<int>::size_type i = 0; i < number.size()-1; i++)
{
cout << number[i] << ",";
}
cout << "and "<<number[number.size()-1]<<" cells";
return 0;
}