#include <stdio.h>
#include <stdlib.h>
#define SIZE 100
int map[SIZE+2][SIZE+2]={0};
int run_test(char ranch[SIZE][SIZE])
{
for(int i=0;i<SIZE+2;i++){
for(int j=0;j<SIZE+2;j++){
map[i][j]=0;
}
}
for(int i=0;i<SIZE;i++){
for(int j=0;j<SIZE;j++){
if(ranch[i][j]=='+')map[i+1][j+1]=1;
}
}
int count=11;
for(int i=1;i<SIZE+1;i++){
for(int j=1;j<SIZE+1;j++){
if(map[i][j]==0){
bool flag=false;
map[i][j]=count;
if(map[i-1][j-1]==0){map[i-1][j-1]=count;flag=true;}
if(map[i-1][j]==0){map[i-1][j]=count;flag=true;}
if(map[i-1][j+1]==0){map[i-1][j+1]=count;flag=true;}
if(map[i][j-1]==0){map[i][j-1]=count;flag=true;}
if(map[i][j+1]==0){map[i][j+1]=count;flag=true;}
if(map[i+1][j-1]==0){map[i+1][j-1]=count;flag=true;}
if(map[i+1][j]==0){map[i+1][j]=count;flag=true;}
if(map[i+1][j+1]==0){map[i+1][j+1]=count;flag=true;}
while(flag){
for(int x=i;x<SIZE+1;x++){
for(int y=1;y<SIZE+1;y++){
if(map[x][y]==count){
flag=false;
if(map[x-1][y-1]==0){map[x-1][y-1]=count;flag=true;}
if(map[x-1][y]==0){map[x-1][y]=count;flag=true;}
if(map[x-1][y+1]==0){map[x-1][y+1]=count;flag=true;}
if(map[x][y-1]==0){map[x][y-1]=count;flag=true;}
if(&map[x][y+1]==0){map[x][y+1]=count;flag=true;}
if(map[x+1][y-1]==0){map[x+1][y-1]=count;flag=true;}
if(map[x+1][y]==0){map[x+1][y]=count;flag=true;}
if(map[x+1][y+1]==0){map[x+1][y+1]=count;flag=true;}
}
}
}
}
count++;
}
}
}
return count-11;
return 0;
}
void main(void)
{
static char ranch[SIZE][SIZE];
for (int c = 0; c < 10; c++)
{
for (int y = 0; y < SIZE; y++)
for (int x = 0; x < SIZE; x++)
ranch[x][y] = ' ';
for (int c = 0; c < 10000; c++)
ranch[rand() % 100][rand() % 100] = '+';
printf("%d\n", run_test(ranch));
}
}