|
First Summer 2006 |
Also, please make sure you
with the Computer Science Department's Statement on Academic Integrity before turning in your assignment.
Enter size of matrix: 12 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Enter size of matrix: 16 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Enter size of matrix: 24 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Consider the guess my number game of chapter 3.
Write a program in which
Before you start think about how you guess.
That's what the computer program should do.
Here's how my program runs (my answers are in red):
Please think of a number between 0 and 100, then press enter. I will guess your number. # I choose 67 I know the number is between 0 and 100 my guess is: 50 How is my guess no.1? [1] Too low [2] Too high [3] Correct Answer: Too low I know the number is between 50 and 100 my guess is: 75 How is my guess no.2? [1] Too low [2] Too high [3] Correct Answer: Too high I know the number is between 50 and 75 my guess is: 62 How is my guess no.3? [1] Too low [2] Too high [3] Correct Answer: Too low I know the number is between 62 and 75 my guess is: 68 How is my guess no.4? [1] Too low [2] Too high [3] Correct Answer: Too high I know the number is between 62 and 68 my guess is: 65 How is my guess no.5? [1] Too low [2] Too high [3] Correct Answer: Too low I know the number is between 65 and 68 my guess is: 66 How is my guess no.6? [1] Too low [2] Too high [3] Correct Answer: Too low I know the number is between 66 and 68 my guess is: 67 How is my guess no.7? [1] Too low [2] Too high [3] Correct Answer: Correct See, I have guessed it in only 7 tries.