Question
Construct a C++ program that will allow two users play tic-tac-toe. The program should ask for moves alternately from player F' and player S'. The
Construct a C++ program that will allow two users play tic-tac-toe. The program should ask for moves alternately from player F' and player S'. The program displays the game position as follows:
1 2 3
4 5 6
7 8 9
The players enter their moves by entering the position number they wish to mark. After each move, the program displays the changed board. A sample board configuration is as follows:- assuming player F' chose 1 followed by 2 and player S' chose 3 and 7.
X X O
4 5 6
O 8 9
Once all 9 positions are chosen, program should determine and print who's the winner.
follow these steps:
1. Create a function void b(char DB[]) - this function should display a board on the screen. It should output each character in an array, putting a newline every three characters.
2. Declare and use an array named tic that should hold digits 'X' and 'O' . Initialize tic[ ] to character digits 1-9. Get a move until all 9 moves used. Validate that moves are between 1-9.
3. Determine and Declare the winner.
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