TicTacToe_2DArray

Download Category:

TicTacToe_2DArray.zip - (418.52 KB)
[
TicTacToe_2DArray/Debug/
TicTacToe_2DArray/Debug/cl.command.1.tlog
TicTacToe_2DArray/Debug/CL.read.1.tlog
TicTacToe_2DArray/Debug/CL.write.1.tlog
TicTacToe_2DArray/Debug/link.5332.read.1.tlog
TicTacToe_2DArray/Debug/link.5332.write.1.tlog
TicTacToe_2DArray/Debug/link.5332-cvtres.read.1.tlog
TicTacToe_2DArray/Debug/link.5332-cvtres.write.1.tlog
TicTacToe_2DArray/Debug/link.command.1.tlog
TicTacToe_2DArray/Debug/link.read.1.tlog
TicTacToe_2DArray/Debug/link.write.1.tlog
TicTacToe_2DArray/Debug/link-cvtres.read.1.tlog
TicTacToe_2DArray/Debug/link-cvtres.write.1.tlog
TicTacToe_2DArray/Debug/mt.command.1.tlog
TicTacToe_2DArray/Debug/mt.read.1.tlog
TicTacToe_2DArray/Debug/mt.write.1.tlog
TicTacToe_2DArray/Debug/rc.command.1.tlog
TicTacToe_2DArray/Debug/rc.read.1.tlog
TicTacToe_2DArray/Debug/rc.write.1.tlog
TicTacToe_2DArray/Debug/TicTacToe_2DArray.exe
TicTacToe_2DArray/Debug/TicTacToe_2DArray.exe.embed.manifest
TicTacToe_2DArray/Debug/TicTacToe_2DArray.exe.embed.manifest.res
TicTacToe_2DArray/Debug/TicTacToe_2DArray.exe.intermediate.manifest
TicTacToe_2DArray/Debug/TicTacToe_2DArray.ilk
TicTacToe_2DArray/Debug/TicTacToe_2DArray.lastbuildstate
TicTacToe_2DArray/Debug/TicTacToe_2DArray.log
TicTacToe_2DArray/Debug/TicTacToe_2DArray.obj
TicTacToe_2DArray/Debug/TicTacToe_2DArray.pdb
TicTacToe_2DArray/Debug/TicTacToe_2DArray.write.1.tlog
TicTacToe_2DArray/Debug/TicTacToe_2DArray_manifest.rc
TicTacToe_2DArray/Debug/vc100.idb
TicTacToe_2DArray/Debug/vc100.pdb
TicTacToe_2DArray/Question.txt
TicTacToe_2DArray/Screenshot_1.jpg
TicTacToe_2DArray/TicTacToe_2DArray.cpp
TicTacToe_2DArray/TicTacToe_2DArray.sln
TicTacToe_2DArray/TicTacToe_2DArray.suo
TicTacToe_2DArray/TicTacToe_2DArray.vcxproj
TicTacToe_2DArray/TicTacToe_2DArray.vcxproj.filters
TicTacToe_2DArray/TicTacToe_2DArray.vcxproj.user
]

Write a program that allows two players (player X and player O) to play a game of tic-tac-toe. Use a two- dimensional char array with three rows and three columns as the game board. Each element of the array should be initialized with an asterisk (*). The players take turns making moves and the program keeps track of whose turn it is. Player X moves first. The program should run a loop that:
Displays the contents of the board array (see prompts and output, below).
Prompts and allows the player whose turn it is to select a location on the board for an X in the case of player X or an O in the case of player O. The program should ask the player to enter the row and column number. Valid row or column numbers are 1, 2, or 3.

The loop terminates when a player has won, or a tie has occurred. If a player has won, the program should declare that player the winner and end. If a tie has occurred, the program should say so and end.

Player X (O) wins when there are three Xs (three Os) in a row on the game board. The Xs (Os) can appear in a row, in a column, or diagonally across the board. A tie occurs when all of the locations on the board are full, but there is no winner.

Input Validation: The program should check the validity of the row and column numbers entered by the players. To be valid, the row and column number must refer to an unoccupied position in the game board. When an invalid entry is made, the program simply redisplays its most recent prompt and attempts to reread the value.

Prompts And Output Labels: The board is displayed as a sequence of three rows, each with three characters. The characters are “X” or “O” or “.” depending on whether player X or player O has chosen that position or whether the position is still unselected. Thus the following:

. . X
O . X
. . .

represents the board when it’s O’s turn and when X has moved twice (to row1/column3 and row2/column3) and O has moved once (to row2/column1).

Players are prompted as “Player X, row and column:” or “Player O, row and column:”. The game’s end is announced either by “Player X wins”, or “Player O wins” or “The cat wins” (in the case of no winner).

Write a Review

Get a fresh solution of this question. Ask it now to our experts.
doubt

Ask Your Question

We have verified professionals who are ready to answer your question.

time

Save Time and Money

We choose experts who can quickly answer your question and that suit your budget.

download

Get Your Answer

Your satisfaction is 100% guaranteed. You can keep on asking questions until you get the answer you need.