From 324ac435a82bc41ffba29b66166fde06e7e54d7f Mon Sep 17 00:00:00 2001 From: Sunny Date: Wed, 26 Nov 2025 10:03:04 -0500 Subject: [PATCH] je sais plus, tbh --- TicTacToe/fonctions.cpp | 13 +++++++++++-- TicTacToe/main.cpp | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/TicTacToe/fonctions.cpp b/TicTacToe/fonctions.cpp index d693e00..179ec34 100644 --- a/TicTacToe/fonctions.cpp +++ b/TicTacToe/fonctions.cpp @@ -17,7 +17,6 @@ using namespace std; extern const int LARGTIC; const string ICONJ1 = { "X" }; const string ICONJ2 = { "O" }; -const string DEFAULT = { " " }; int codeConsole = 0; fstream monFlux; @@ -88,7 +87,7 @@ void afficherImageMenu(std::fstream& monFlux) { //Général (plusieurs options) void initTab(string grid[][LARGTIC]) { for (int i = 0; i < LARGTIC; i++) { - for (int j = 0; j < LARGTIC; i++) { + for (int j = 0; j < LARGTIC; j++) { grid[i][j] = " "; } } @@ -175,6 +174,14 @@ void tourJoueur(string grid[][LARGTIC], int joueur) { cout << "\nEntrez une coordonnee horizontale : "; cin >> horizontale; + while (grid[verticale][horizontale] == ICONJ1 || grid[verticale][horizontale] == ICONJ2) { + cout << "\n\nVeuillez choisir une case vide.\n" + << "\n\nEntrez une coordonnee verticale : "; + cin >> verticale; + cout << "\nEntrez une coordonnee horizontale : "; + cin >> horizontale; + } + if (joueur == 1) { grid[verticale - 1][horizontale - 1] = ICONJ1; } @@ -247,6 +254,8 @@ bool verifFinMatch(std::string grid[][LARGTIC]) { } void afficherFinMatch(string grid[][LARGTIC], int gagnant, int nbJoueurs) { + afficherImageTableau(grid); + if (nbJoueurs == 1) { if (gagnant == 1) { cout << "\n\nLe joueur a gagne la partie!"; diff --git a/TicTacToe/main.cpp b/TicTacToe/main.cpp index 118c197..93c3e34 100644 --- a/TicTacToe/main.cpp +++ b/TicTacToe/main.cpp @@ -17,7 +17,7 @@ int main() { srand(time(NULL)); char choix; - string grid[LARGTIC][LARGTIC] = {" ", " ", " "," ", " ", " ", " ", " ", " "}; + string grid[LARGTIC][LARGTIC]; do { initTab(grid);