Problem
uess the Number Problem
In a simple number game your opponent thinks of a secret number between l and 100. In no more than 10 guesses you have to try to guess the number. After each guess your opponent tells you if your guess was too high, too low or correct. Your opponent also keeps track of how many guesses you have had and tells you the game is over when you use all of your ten guesses or when you guess the number correctly.
Describe an algorithm which takes the role of your opponent in this game. Include in your solution a subprogram which checks for illegal guesses (those less than l or greater than 100). Include also the subprogram which generates a secret number between 1 and 100. Do not expand this but assume it is available.T
Do'stlaringiz bilan baham: |