Mystery Number
Closed
clairehgh
Posted messages
6
Status
Member
-
crapoulou Posted messages 28002 Registration date Status Moderator, Security Contributor Last intervention -
crapoulou Posted messages 28002 Registration date Status Moderator, Security Contributor Last intervention -
Hello, I have this statement to solve in #C, can someone help me find the code to follow? A big thank you in advance :)
A player A proposes an integer between 1 and 100.
A player B must guess this number with the help of the computer which will specify the range within which the player must make their next guess.
Examples:
• Please propose a mysterious number between 1 and 100 now
• Please propose a mysterious number between 1 and 60 now
• Please propose a mysterious number between 40 and 60 now
• Please propose a mysterious number between 50 and 60 now
A player A proposes an integer between 1 and 100.
A player B must guess this number with the help of the computer which will specify the range within which the player must make their next guess.
Examples:
• Please propose a mysterious number between 1 and 100 now
• Please propose a mysterious number between 1 and 60 now
• Please propose a mysterious number between 40 and 60 now
• Please propose a mysterious number between 50 and 60 now
4 answers
-
We will not do your exercise for you.
Please describe your problem precisely and post the code you have already written.
Click here for writing tips for your messages and here regarding homework or final projects.
To post your code, please remember to use syntax highlighting.
--
I mainly work in VB6 and VB.NET, with a bit of C#, but moderation often brings me into other languages.
In VB.NET, be sure to enable "Option Explicit" and "Option Strict". -
You see, NHenry, a moderator, is asking you the same thing as I am.....
--
When I was little, the Dead Sea was only sick.
George Burns -
To assist the computer, here is what I suggest: store the possible interval lengths in an array. Based on the example you chose, this array will contain: 100, 60, 20, 10. Each time player B makes a choice, the interval will reduce until the last possible length (here, 10).
We will call "i_ecart" the current length of the computer's assistance interval. Initially, it will be set to 0 (to point to the first element of the array).
For a first task, you will write a function that takes two integers as input: "i_ecart" and the value chosen by player B. Your function will be responsible for displaying the corresponding assistance message.
Example: if I call this function with "i_ecart" = 1 and the value chosen by player B = 45, then your function will display:
Please propose a mysterious number between 15 and 75
(75 - 15 = 60)
Helping is my nindo -
Hello,
Thank you for staying on the discussion created initially:
https://forums.commentcamarche.net/forum/affich-34086565-creer-un-jeu
Click the blue button 'Reply' / 'Reply to topic' to stay in the same discussion.
Best regards.
Crapoulou, CCM Moderator.