Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
Keyword to skip the rest of a for/while-loop and continue to perform the next.
for (/* something #1 */ )
{
//This line is always executed
if (/* something #2 */) continue;
//This line is only executed if 'something #2' is false
}
//From http://www.richelbilderbeek.nl/CppCountDeadEnds.htm
const int CountDeadEnds(const std::vector<std::vector<int> >& maze)
{
int nDeadEnds = 0;
{
{
if (maze[y][x] != 0) continue; //Continue if here is a wall
= (maze[y+1][x ] == 1 ? 1 : 0)
+ (maze[y-1][x ] == 1 ? 1 : 0)
+ (maze[y ][x+1] == 1 ? 1 : 0)
+ (maze[y ][x-1] == 1 ? 1 : 0);
if (nWalls == 3) ++nDeadEnds;
}
}
return nDeadEnds;
}
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.