From cfc83ee2ff6b6659fe18804e827e7bbd21712f67 Mon Sep 17 00:00:00 2001 From: Yi Jianlong Date: Mon, 16 Oct 2023 21:07:43 +0800 Subject: [PATCH] [fix] fix issue in mine sweep template (#144) replace 'and' with '&&' because 'and' does not always work. fix index out of bound issue though the compiler doesn't check it. --- platform/windows/templates/sweepminer/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/windows/templates/sweepminer/main.cpp b/platform/windows/templates/sweepminer/main.cpp index 57096a2c..583bd442 100644 --- a/platform/windows/templates/sweepminer/main.cpp +++ b/platform/windows/templates/sweepminer/main.cpp @@ -199,7 +199,7 @@ int main() int totalblocks = 0; for (int i = 0; i < ROWS; ++i) { for (int j = 0; j < COLUMNS; ++j) { - if (gameboard[i][j].getType() >= 1 and gameboard[i][j].isRevealed() == false) { + if (gameboard[i][j].getType() >= 1 && gameboard[i][j].isRevealed() == false) { totalblocks++; } } @@ -357,7 +357,7 @@ void countMinesInNeighbors(int i, int j) { if (gameboard[i][j+1].getType() == MINE) { count++; } - if ((i+1) <= ROWS) { + if ((i+1) < ROWS) { if (gameboard[i+1][j+1].getType() == MINE) { count++; }