C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 07-29-2002, 12:29 PM   #1
Registered User
 
Join Date: Jul 2002
Posts: 5
Question high or low !

Hi
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   Reply With Quote
Old 07-29-2002, 12:34 PM   #2
Green Member
 
Cshot's Avatar
 
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   Reply With Quote
Old 07-29-2002, 12:44 PM   #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   Reply With Quote
Old 07-29-2002, 01:24 PM   #4
Green Member
 
Cshot's Avatar
 
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   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 03:41 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22