![]() |
| | #1 |
| Registered User Join Date: Jul 2002
Posts: 5
| Maybe this question is redundant and I apologise if it is ,cause I tried searching I was not able to find the exact answer . If I want to find out if the user-typed value is too low or too high ,how I can do it ? Like I have the user enter 78 ,but the value that he shd have typed is 80 .Then I cant just say too low .I will have to say something like "nearer to the actual value " .I have an hint thats says use Binary search .But I dont understand how it works .. Can anybody enlighten me on this? Thanks for your time and patience . |
| Beginner2002 is offline | |
| | #2 |
| Green Member Join Date: Jun 2002
Posts: 892
| First you would compare the user's input to the original number and specify whether it's lower or higher. Then you can take the absolute value of the difference and specify the relative difference between the numbers. Say for example it's +- 5 within the number then you can comment that the user is getting real close. I'm not sure what a binary search would have to do with this problem. Unless you're maybe inserting the user's guesses into a tree and depending on how where it traverses down the tree, you can give feedback based on the user's previous input. |
| Cshot is offline | |
| | #3 |
| Registered User Join Date: Jul 2002
Posts: 5
| clarification Hi You are right .I think the use of Binary search is necessary because the next response depends on the users' previous responses . There are 3 responses - >Correct >Too low .Try again >Too high .Try again . it says " If the player's guess is incorrect ,your program should loop until the player finally gets the number right .Your program shd keep telling the player Too high or Too low to help the player "zero in" on the correct answer. Can you give me a good example/link etc for this ? Thanks for your time and patience . |
| Beginner2002 is offline | |
| | #4 |
| Green Member Join Date: Jun 2002
Posts: 892
| Here's a brief intro: http://oopweb.com/Algorithms/Documen...iles/s_bin.htm There's plenty of resources out there that'll give you example code for binary trees. |
| Cshot is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| RandF function. (Rand Float) | kevinawad | C++ Programming | 12 | 08-13-2009 04:32 AM |
| Ace high and low in card game | ninety3gd | C Programming | 3 | 05-10-2009 08:16 PM |
| C/C++, low or high level? | Sentral | General Discussions | 4 | 01-23-2007 11:43 PM |
| what is the significance of low order and high order bits | Shadow12345 | Windows Programming | 1 | 11-16-2002 11:46 AM |
| low value, high value and increment | Unregistered | C Programming | 2 | 11-25-2001 09:01 AM |