0% found this document useful (0 votes)
31 views3 pages

CS&141 - Lab #7: Log of Execution (User Input Underlined)

The document describes a tic-tac-toe game programmed with a two-dimensional array that prompts the user to choose who goes first and allows multiple games. The computer implements a strategy to complete two-in-a-row if possible or block the user's two-in-a-row. It also recognizes a win by either player or a cat's game draw.

Uploaded by

Lnw Sun
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views3 pages

CS&141 - Lab #7: Log of Execution (User Input Underlined)

The document describes a tic-tac-toe game programmed with a two-dimensional array that prompts the user to choose who goes first and allows multiple games. The computer implements a strategy to complete two-in-a-row if possible or block the user's two-in-a-row. It also recognizes a win by either player or a cat's game draw.

Uploaded by

Lnw Sun
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

CS&141 Lab #7

Programming Projects Page 499 5.


Use a two-dimensional array to write a game of Tic-Tac-Toe that represents the board.
Your program should prompt the user to choose who goes first and the user can play the game
multiple times. The implemented strategy will complete a 2-in-a-row if possible and will otherwise
block a user 2-in-a-row. The program recognizes a win by either player and a cat's game situation
when it is the computer's turn.

Log of execution (user input underlined)


Let's play tic tac toe
Do you want to go first? y
Your move? 2 <enter>
2
------------|
|
|
|
------------|
| X |
|
------------|
|
|
|
------------I move to 1, 3
------------|
|
| O |
------------|
| X |
|
------------|
|
|
|
-------------

Your move? 3
1
------------|
|
| O |
------------|
| X |
|
------------| X |
|
|
------------I move to 1, 2
------------|
| O | O |
------------|
| X |
|
------------| X |
|
|
------------Your move? 1
1
------------| X | O | O |
------------|
| X |
|
------------| X |
|
|
------------I move to 2, 1
------------| X | O | O |
------------| O | X |
|
------------| X |
|
|
-------------

Your move? 3
3
------------| X | O | O |
------------| O | X |
|
------------| X |
| X |
------------You win
------------| X | O | O |
------------| O | X |
|
------------| X |
| X |
------------Want to play again? y
...Steps Skipped...
I move to 2, 3
I win
------------| X |
| O |
------------|
| X | O |
------------| X |
| O |
------------Want to play again?

You might also like