From 6e3cfc6d971ae6afd9accee1af3dc4425b3ee215 Mon Sep 17 00:00:00 2001 From: Sabina Grisi Date: Fri, 9 Feb 2024 21:08:58 +0100 Subject: [PATCH] Pruefung auf Gewinn fuer Position 1, 2, 3 --- src/TicTacToe.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/TicTacToe.c b/src/TicTacToe.c index 3c7d1d1..b8d825d 100644 --- a/src/TicTacToe.c +++ b/src/TicTacToe.c @@ -48,7 +48,19 @@ int main() { } drawBoard(pos1, pos2, pos3, pos4, pos5, pos6, pos7, pos8, pos9); + // Prüfung auf Gewinn + if (pos1 == player && pos2 == player && pos3 == player) { + if(player == 10){ + printf("\nSpieler X hat gewonnen!\n\n"); + break; + }else{ + printf("\nSpieler O hat gewonnen!\n\n"); + break; + } + } + player = switchPlayer(player); + } return 0; }