Write a program that will allow two users to play tic-tac-toe. The program should ask for moves alternately from player X and player O. The program displays the game positions as follows:
1 2 3
4 5 6
7 8 9
The players enter their moves by entering the position numbers they wish to mark. After each move, the program displays the changed board. A sample board configuration is as follows:
X X O
4 5 6
O 8 9
IMPLEMENTATION:
Functions (mandatory):
void printboard (char tictactoe_board[]);
( displays the board layout)
void checkwinners(char tictactoe_board[], char& result);
(computes the winner if any, if 'X' is the winner result is X and if 'O' is winner, result set to 'O')
SAMPLE RUN:
1 2 3
4 5 6
7 8 9
Enter move:
2
1 X 3
4 5 6
7 8 9
Enter move:
5
1 X 3
4 O 6
7 8 9
Enter move:
8
1 X 3
4 O 6
7 X 9
Enter move:
9
1 X 3
4 O 6
7 X O
Enter move:
7
1 X 3
4 O 6
X X O
Enter move:
1
O X 3
4 O 6
X X O
Enter move:
4
O X 3
X O 6
X X O
Enter move:
5
That space is taken.
O X 3
X O 6
X X O
Enter move:
3
O X O
X O 6
X X O
Enter move:
2
That space is taken.
O X O
X O 6
X X O
Enter move:
6
O X O
X O X
X X O
Game over!
NO WINNERS!