Question
In C++ and with comment please. Sample Display Columns 1 2 3 Row 1: * * * Row 2: * * * Row 3: *
In C++ and with comment please.
Sample Display
Columns
1 2 3
Row 1: * * *
Row 2: * * *
Row 3: * * *
Player X's turn.
Enter a row and column to place an X.
Row: 1
Column: 3
Columns
1 2 3
Row 1: * * X
Row 2: * * *
Row 3: * * *
Player O's turn.
Enter a row and column to place an O.
Row: 1
Column: 2
Columns
1 2 3
Row 1: * O X
Row 2: * * *
Row 3: * * *
Player X's turn.
Enter a row and column to place an X.
Row: 2
Column: 3
Columns
1 2 3
Row 1: * O X
Row 2: * * X
Row 3: * * *
Player O's turn.
Enter a row and column to place an O.
Row: 2
Column: 2
Columns
1 2 3
Row 1: * O X
Row 2: * O X
Row 3: * * *
Player X's turn.
Enter a row and column to place an X.
Row: 3
Column: 3
Columns
1 2 3
Row 1: * O X
Row 2: * O X
Row 3: * * X
Columns
1 2 3
Row 1: * O X
Row 2: * O X
Row 3: * * X
Player 1 (X) WINS!!!!!
Tic-Tac-Toe Game Write a modular program that allows two players to play a game of tic-tac-toe. Use a twodimensional char array with 3 rows and 3 columns as the game board. Each element of the array should be initialized with an asterisk The program should display the initial board configuration and then start a loop that does the following: Allow player 1 to select a location on the board for an X by entering a row and column number. Then redisplay the board with an X replacing the n the chosen location f there is no winner yet and the board is not yet full, allow player 2 to select a location on the board for an O by entering a row and column number. Then redisplay the board with an O replacing the in the chosen location. The loop should continue until a player has won or a tie has occurred, then display a message indicating who won, or reporting that a tie occurred. Player 1 wins when there are three Xs in a row, a column, or a diagonal on the game board Player 2 wins when there are three Os in a row, a column, or a diagonal on the game board A tie occurs when all of the locations on the board are full, but there is no winner. Input Validation: Only allow legal moves to be entered. The row must be 1, 2, or 3. The column must be 1, 2, or 3. The (row, column) position entered must currently be empty (i.e., still have an asterisk in it)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started