Browse Source

Write checkDiagonalLR function

remotes/origin/Ahmad
fdai7726 11 months ago
parent
commit
234b2bf103
  1. 24
      src/main/c/VierGewinnt.c

24
src/main/c/VierGewinnt.c

@ -181,3 +181,27 @@ int checkVertical(char board[ROWS][COLS], char player) {
} }
return 0; return 0;
} }
// Write checkDiagonalLR function
int checkDiagonalLR(char board[ROWS][COLS], char player) {
for (int row = 0; row <= ROWS - 4; row++) {
for (int col = 0; col <= COLS - 4; 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