Question: Everyone knows how to play tic - tac - toe. At the end of a tic - tac - toe match, we are left with

Everyone knows how to play tic-tac-toe. At the end of a tic-tac-toe match, we are left with a board with Xs and Os. In this problem, we will refer to the final state of a tic-tac-toe board as a configuration. Using 0(resp.,1) to characterize 0(resp., X), and 2 to characterize empty squares, we can represent the configuration of a tic-tac-toe board with an integer. For example:
00
0xx=100011110
x0
00x
000
xx,=112210
xx=1211221
0
Note that not all configurations have 9 digits, due to some having leading 0's. Your task is to write a function ValidateBoard that takes a configuration as input, and returns the string x wins!, O wins!, It's a draw!, or Invalid configuration!, depending on the configuration. An invalid configuration is a configuration that is impossible to achieve if the rules are followed. For example, 111111111 is an invalid configuration, as it is impossible for a tic-tac-toe board to have 9xs.Below is an example of how your program should behave:Enter configuration: 112210Result: 0 wins!
WRITE THE CODE IN C++
 Everyone knows how to play tic-tac-toe. At the end of a

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!