C++ (Array) Tic-Tac-Toe Game Write a program that allows two players to play a g
ID: 3768303 • Letter: C
Question
C++ (Array)
Tic-Tac-Toe Game
Write a program that allows two players to play a game of tic-tac-toe. Using a two-dimensional char array with three rows and three columns as the game board. Each element of the array should be intialized with a number from 1 - 9 (like below):
1 2 3
4 5 6
7 8 9
The program should run a loop that
Displays the contents of the board array
allows player 1 to select the location on the board for an X
allows player 2 to select the location on the board for an O
determine whether a player has won or a tie has occurred. If a player has won the program should declare that player the winner and end. If a tie has occurred, the program should say so and end.
A player wins when they have three in a row on a game board. They can appear in a row, column or diagonally across the board. A tie occurs when all the locations are filed but there is no winner.
Explanation / Answer
#include #include using namespace std; const int SIZE = 3; char a[3][3] = { {'*','*','*'}, {'*','*','*'}, {'*','*','*'} }; char b = '0'; void draw(); bool getinputP1(); bool getinputP2(); bool checkwinP1(); bool checkwinP2(); int main() { draw(); coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.