Write a tic-tac-toe game to be played between two players. Use an array to emula
ID: 3618040 • Letter: W
Question
Write a tic-tac-toe game to be played between two players. Use an array to emulate
the game board. The array can be one dimensional or two-dimensional. Initialize
each element of the array to "_" (underscore). YOur program should start by
displaying the initial board and then let player X and player O take turns.
Associate X with player X's moves and O with O's. Determine as the game
progresses whether there is a winner or the game tied. If one of the player wins the
game identify it as player X or O. All Xs or Os in a row, in a column or in a diagonal
is a winning condition. When no more element is left the game is a tie.
Expected Output:
(i) X wins.
Columns
1 2 3
Row 1: _ _ _
Row 2: _ _ _
Row 3: _ _ _
Player X's turn.
Enter a row and column to place an X.
Row: 1
Column: 1
Columns
1 2 3
Row 1: X _ _
Row 2: _ _ _
Row 3: _ _ _
Player O's turn.
Enter a row and column to place an O.
Row: 2
Column: 2
Columns
1 2 3
Row 1: X _ _
Row 2: _ O _
Row 3: _ _ _
Player X's turn.
Enter a row and column to place an X.
Row: 1
Column: 3
Columns
1 2 3
Row 1: X _ X
Row 2: _ O _
Row 3: _ _ _
Player O's turn.
Enter a row and column to place an O.
Row: 1
Column: 2
Columns
1 2 3
Row 1: X O X
Row 2: _ O _
Row 3: _ _ _
Player X's turn.
Enter a row and column to place an X.
Row: 2
Column: 1
Columns
1 2 3
Row 1: X O X
Row 2: X O _
Row 3: _ _ _
Player O's turn.
Enter a row and column to place an O.
Row: 3
Column: 3
Columns
1 2 3
Row 1: X O X
Row 2: X O _
Row 3: _ _ O
Player X's turn.
Enter a row and column to place an X.
Row: 1
Column: 3
That location is not available. Select another location.
Row: 3
Column: 1
Columns
1 2 3
Row 1: X O X
Row 2: X O _
Row 3: X _ O
Columns
1 2 3
Row 1: X O X
Row 2: X O _
Row 3: X _ O
Player 1 (X) WINS!!!!!