# Anyone know how to Clear the adjacent square in one go in minesweeper

Page 1 of 1

## 1 Replies - 703 Views - Last Post: 04 November 2009 - 12:48 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=136472&amp;s=16db39e5ee6446c49d3b8040070037df&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Yummy90

• New D.I.C Head

Reputation: 0
• Posts: 3
• Joined: 27-October 09

# Anyone know how to Clear the adjacent square in one go in minesweeper

Posted 03 November 2009 - 11:30 PM

I dunno how to clear the blank square in one go..... so far i have did this....
Anyone know how to do?

```int e,f,g=0;
if(action=='C')
{

/*** Checking whether the square already opened before or not ***/
if (Board[InitPox][InitPoy].open == 0)	  /* If the square has not been opened yet */
{
Beep(500,200);
printf ("The square is opened! ^^/> \n\n");

/*** Display the number of mine on the square if the square is adjacent to the location of mine ***/
for (e=-1;e<2;e++)
{
for (f=-1;f<2;f++)
{
if (Mines[InitPox + e][InitPoy + f].mine == '*')
{
g++;
}

else
if (Mines[InitPox + e][InitPoy +f].mine == ' ')

for (e=-1;e<2;e++)
{
for (f=-1;f<2;f++)
{
if (Mines[e][f].mine == ' ')
printf("%i",Board[e][f].numMines);
}
}

if(Mines[InitPox][InitPoy].mine == '*')
{

Beep(900,200);
Beep(700,200);
Beep(500,200);
printf ("Boom! Your turtle is dead...\n\n");
printf ("****** Game Over! You Lose ! ******\n");
displayReveal(Board,Mines);
exit (1);
}
}
}

Board[InitPox][InitPoy].numMines = g;
}

if (Board[InitPox][InitPoy].open == 1)	  /* If the square has been opened before */
{
printf ("The square already opened ! \n\n");
}

Board[InitPox][InitPoy].open = 1;
}

}  /* end of ClearSq() */
```

Is This A Good Question/Topic? 0

## Replies To: Anyone know how to Clear the adjacent square in one go in minesweeper

### #2 gronk

• D.I.C Head

Reputation: 13
• Posts: 168
• Joined: 28-October 09

## Re: Anyone know how to Clear the adjacent square in one go in minesweeper

Posted 04 November 2009 - 12:48 AM

Looking at the code it seems you haven't tried anything yet for clearing all the blank squares. What's your algorithm for doing that? You could use either iteration or recursion, but you will need to decide how it'll work before you can write the code for it.
Was This Post Helpful? 0

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }