Browse Source

Write checkVertical function

remotes/origin/Ahmad
fdai7726 11 months ago
parent
commit
46f3cb93c6
  1. 15
      src/main/c/VierGewinnt.c

15
src/main/c/VierGewinnt.c

@ -166,3 +166,18 @@ int checkHorizontal(char board[ROWS][COLS], char player) {
} }
return 0; return 0;
} }
//Write checkVertical function
int checkVertical(char board[ROWS][COLS], char player) {
for (int col = 0; col < COLS; col++) {
for (int row = 0; row <= ROWS - 4; row++) {
if (board[row][col] == player &&
board[row + 1][col] == player &&
board[row + 2][col] == player &&
board[row + 3][col] == player) {
return 1; // Gewonnen
}
}
}
return 0;
}
Loading…
Cancel
Save