Professional Documents
Culture Documents
Dear SD
Dear SD
This program is, as the title states, a tic-tac-toe program. I was thinking of a way to
implement the two-dimensional array and the first thing that came to my mind was a tic-tac-
toe program. This ever-popular game can be played against two people and in the end the
game will end telling which person is the winner and which person has lost. Although this
program does use a multi-dimensional array, it does also use a single dimensional array. The
multi-dimensional array is used to store the X’s and O’s that the players enter. The single
dimensional array is used to store the number of times that either X or O has won. The other
thing that it stores is the number of cat’s game that has been played.
To do this, I had to make a program that was much more complicated than I had
thought it to be. I first started out by defining both of my arrays. After this I began to ask the
two players to enter the values for their desired move. Each time a value is entered by a user
the program test to make sure that spot hasn’t been previously picked just to make sure that no
cheating goes on. No test for a 3 in a row is performed within the first four moves since it
isn’t possible to win in the first four moves no matter how careless an opponent may be. After
the first four moves a new test is added to the procedure. This new test is to test if the values
entered by the user are linked together, three in a row, diagonally, horizontally, or vertically.
dimensional array. The one corresponds for the first player winning. The two means that the
second player has won. The three means that it was a cat’s game. Each time a game is over,
the program saves a number in the correct element. After all the games have been played, the
total number of ones, twos, and three’s are all added together. The last thing that the program
does is tell which player has the most wins or if there is a draw.