Browse Source

Write checkDiagonalRL function

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

15
src/main/c/VierGewinnt.c

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