Tic Tac Toe
Tic Tac Toe
Tic Tac Toe
#include <vector>
int main() {
vector<vector<char>> board(3, vector<char>(3, ' ')); // Initialize an empty
board
char currentPlayer = 'X';
bool gameover = false;
while (!gameover) {
printBoard(board);
getPlayerMove(board, currentPlayer);
if (checkWin(board, currentPlayer)) {
cout << "Player " << currentPlayer << " wins!" << endl;
gameover = true;
} else if (checkDraw(board)) {
cout << "It's a draw!" << endl;
gameover = true;
}
// Switch players
currentPlayer = (currentPlayer == 'X') ? 'O' : 'X';
}
return 0;
}