CS201 – Spring 2003

Prof. Hartman

Homework #9

Due Friday, April 18th by 5:00 pm

 

 

1.      Create a program that will allow 2 users to play tic-tac-toe with one another. The program should alternate between the X-player and the O-player, giving them one turn each until either player has won or the game ends in a tie. Players will enter their coordinates as two integers in the range 0-2 (or 1-3, however you have your columns set up) where the first number is the row coordinate and the second is the column. The program should check for a winner or a tie at the end of each move by each player.

The program should also output the tic-tac-toe board after each move before asking for input. If a space is empty on the board, your program should output a space. An example of the output might be

           

X   O
  X
X O O
 
Player X enter row and column coordinates: 0 1
 
X X O
  X
X O O
 
Player O enter row and column coordinates: 1 2
 
X X O
  X O
X O O
 
Player O wins!
 

2.      Write a program that will allow the user to enter a C-style string (i.e., array of characters, null terminated), and then print it out in reverse order. The function that prints it out should be recursive.