Browse Source

Write checkVertical function

main^2
fdai7726 11 months ago
committed by Peter Wiebe
parent
commit
0ee87c82d7
  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;
}
//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