?
Solved

Design an algorithm that plays game of fork with limited chances

Posted on 2003-03-31
6
Medium Priority
?
180 Views
Last Modified: 2013-12-04
the game is guessing a single number that the computer randomly hides within a give range lets say the user enters  a number we output results. if it is not clear dont hesitate to ask me.
dapro1284@yahoo.com
0
Comment
Question by:switloic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 

Author Comment

by:switloic
ID: 8240554
to modify the game --
0
 
LVL 10

Accepted Solution

by:
substand earned 200 total points
ID: 8240799
are you using any specific language?  here's a generic example in c:

#define MINNUM 1
#define MAXNUM 10

int randomInt(int low, int high);

int main()
{
int seed=time(NULL);
int compNum=randomInt(MINNUM,MAXNUM);
int userNum;


srand(seed);

printf("Pick Num between %d and %d.", MINNUM,MAXNUM);
scanf("%d",&userNum);

if (userNum==compNum) printf("You win!");
else printf("You lose!  The number was %d", compNum);

return 0;
}

int randomInt(int low, int high)
{  int k;
    double d;
    d = (double) rand() / (double)(RAND_MAX + 1);
    k = d * (high – low + 1) + low;
    return k;
}
0
 
LVL 24

Expert Comment

by:SunBow
ID: 8241917
> to modify the game --

Have computer use random number to decide which program code to execute next. This is not a fork operation. It is beneficial for modeling. As a game, the human types text, and the computer (doctor) can reply with different phrases each time, even if user re-enters tha same thing.
0
 

Expert Comment

by:CleanupPing
ID: 9446618
switloic:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 10

Expert Comment

by:substand
ID: 9447758
considering my answer is the only complete one, i vote for myself receiving points.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question