Question: Please write a C++ program to check a tic-tac-toe game and show its winning result in detail. This is an application program of a 3-dimensional

Please write a C++ program to check a tic-tac-toe game and show its winning result in detail. This is an application program of a 3-dimensional list or array.

Your complete test run output must look as follows. This test really checks to make sure your program is performing perfectly to check every possible winning situation for X and O.

Welcome to the TicTacToe program by "you"!

GAME 0 is as follows:

OOO

OOO

OOO

O won by row 1

O won by row 2

O won by row 3

O won by column 1

O won by column 2

O won by column 3

O won by diagonal 1

O won by diagonal 2

GAME 1 is as follows:

XXX

XXX

XXX

X won by row 1

X won by row 2

X won by row 3

X won by column 1

X won by column 2

X won by column 3

X won by diagonal 1

X won by diagonal 2

GAME 2 is as follows:

XOX

XXO

XOO

X won by column 1

X won by diagonal 2

GAME 3 is as follows:

XOO

OXO

XXO

O won by column 3

GAME 4 is as follows:

XOX

OXO

XOO

X won by diagonal 2

GAME 5 is as follows:

OXO

XOX

XOX

It is a tie.

Please enter your game board (* to exit)>OOOXOXOXO

Your game board is as follows:

OOO

XOX

OXO

O won by row 1

O won by diagonal 1

O won by diagonal 2

Please enter your game board (* to exit)>OXOOXOOXO

Your game board is as follows:

OXO

OXO

OXO

O won by column 1

X won by column 2

O won by column 3

Please enter your game board (* to exit)>XOXXXXOXO

Your game board is as follows:

XOX

XXX

OXO

X won by row 2

Please enter your game board (* to exit)>*

Thank you for playing this game designed by "you"

Your main program must have the following code to set up the preset 6 games.

# MAIN PROGRAM: ================================================.

print ("Welcome to the TicTacToe program designed by "you")

O = 'O' # player O

X = 'X' # player X

tlist = [ [ [O,O,O], # Game 0 # tlist is like a 3-dimensional array.

[O,O,O],

[O,O,O] ] ,

[ [X,X,X], # Game 1

[X,X,X],

[X,X,X] ] ,

[ [X,O,X], # Game 2

[X,X,O],

[X,O,O] ] ,

[ [X,O,O], # Game 3

[O,X,O],

[X,X,O] ] ,

[ [X,O,X], # Game 4

[O,X,O],

[X,O,O] ] ,

[ [O,X,O], # Game 5 # It is a tie.

[X,O,X],

[X,O,X] ] ]

for i in range(6): # 6 games to check one by one

print("GAME", i ," is as follows:")

show( tlist[i] )

checkwin( tlist[i] )

# More code to keep getting input from the user for the next game

# Stop this program if users input is *

# Thank the user before exit

# End of Program ########################################

You must define show( ) function to show the 3X3 game board.

You must define checkwin( ) function to check all the winning situations for X and O.

You must define 8 functions to check 8 possibilities to win:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!