Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 182
  • Last Modified:

Design an algorithm that plays game of fork with limited chances

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
switloic
Asked:
switloic
1 Solution
 
switloicAuthor Commented:
to modify the game --
0
 
substandCommented:
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
 
SunBowCommented:
> 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
 
CleanupPingCommented:
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
 
substandCommented:
considering my answer is the only complete one, i vote for myself receiving points.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now