Question: IN C++ PLEASE!! THANK YOU The following program is the base for the game: tic-tac-toe. The main function and program structure is given, dont modify
IN C++ PLEASE!! THANK YOU
The following program is the base for the game: tic-tac-toe. The main function and program structure is given, dont modify them. Complete three functions as required. Compile and run this program, and then you can play the game. Have fun!
#include
using namespace std;
const int DIM=3;
char chessboard[DIM][DIM];
//initChessBoard
void initChessBoard(char cb[][DIM])
{
//set all the elements of the ChessBoard to blanks
//Complete this part in the following:
}
//printChessBoard
void printChessBoard(char cb[][DIM])
{
//print all the elements of the chessBoard with each row in one line
//Complete this part in the following:
}
//putChequer
bool putChequer(char cb[][DIM], int i, int j, char x)
{
/* if i and j are not out of bound(that is, i and j are in the range of 0 and DIM-1) and cb[i][j] is not occupied(that is, the value of cb[i][j] is blank), set cb[i][j] to be the value of x and return true. Otherwise, return false.*/
// Complete this part in the following:
}
//judge the state of the game. The player has put x in the position (row, col).
// If all the elements in this row are x, x wins
// If all the elements in this column are x, x wins.
// If x is in the main diagonal, and if all the elements in the main diagonal are x, x wins.
// If x is in the opposite diagonal, and if all the elements in the opposite diagonal are x, x wins.
bool state(char cb[][DIM], int row, int col, char x)
{
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
