Tic-tac-toe

Try creating your own tic-tac-toe program! Some suggestions:

  • Store the tic-tac-toe board as a 2D array with three rows and three columns
  • Have the game switch between an X and O player, repeatedly asking each to choose a row and column number to mark
  • Display an updated tic-tac-toe board at the end of each player’s turn
  • Detect when a player won the game or if moves can no longer be played

Example Program Usage:

          #           #
          #           #
    1     #     2     #     3
          #           #
          #           #
# # # # # # # # # # # # # # # # #
          #           #
          #           #
    4     #     5     #     6
          #           #
          #           #
# # # # # # # # # # # # # # # # #
          #           #
          #           #
    7     #     8     #     9
          #           #
          #           #

Select a box to mark with X: