[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.
This commit is contained in:
Yi Jianlong 2023-10-16 21:07:43 +08:00 committed by GitHub
parent 814f3a28db
commit cfc83ee2ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -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++;
}