Browse Source

Write checkHorizontal function

remotes/origin/Ahmad
fdai7726 11 months ago
parent
commit
1e1e37b791
  1. 16
      src/main/c/VierGewinnt.c

16
src/main/c/VierGewinnt.c

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