< previous page page_766 next page >

Page 766
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Add up the points in the hand and print one of the following messages.
Below 13 points,
Pass
From 13 through 16 points,
Bid one of a suit
From 17 through 19 points,
Bid one no trump
From 20 through 22 points,
Bid one of a suit
Over 22 points,
Bid two of a suit

2. Write an interactive program that plays tic-tac-toe. Represent the board as a three-by-three character array. Initialize the array to blanks and ask each player in turn to input a position. The first player's position will be marked on the board with an O, and the second player's position will be marked with an X. Continue the process until a player wins or the game is a draw. To win, a player must have three marks in a row, in a column, or on a diagonal. A draw occurs when the board is full and no one has won.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Each player's position should be input as indices into the tic-tac-toe board that is, a row number, a space, and a column number. Make the program user friendly.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
After each game, print out a diagram of the board showing the ending positions. Keep a count of the number of games each player has won and the number of draws. Before the beginning of each game, ask each player if he or she wishes to continue. If either player wishes to quit, print out the statistics and stop.
3. Write a C++ program to read in two 2-dimensional arrays, and then multiply one by the other. This is called matrix multiplication. For example, if firstArray (a 2-row by 2-column array) appears as
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
2  7
9  3
and secondArray (a 2-row by 1-column array) appears as
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
8
6
then the product matrix is
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
productMatrix[0][0] = 2 * 8 + 7 * 6
productMatrix[1][0] = 9 * 8 + 3 * 6
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Matrix multiplication can be done only if the number of columns in the multiplicand (the first array) equals the number of rows in the multiplier (the second array).
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
The program should read in the two arrays, test to see if multiplication is possible, and then multiply them if it is. The output will be a printout of the two arrays and will either output the product array or print a message saying that multiplication is not possible.
4. Photos taken in space by the Galileo spacecraft are sent back to earth as a stream of numbers. Each number represents a level of brightness. A large number represents a high brightness level, and a small number represents a low level. Your job is to take a matrix (a two-dimensional array) of the numbers and print it as a picture.

 
< previous page page_766 next page >