English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

im gonna create the computer version of the game mastermind, i cant create a source code, im supposed to use the rand() function

2007-01-05 16:57:35 · 3 answers · asked by Sammy Baby 1 in Computers & Internet Programming & Design

3 answers

rand() will just give you a random number. thats it! you need to know MUCH more than that to create a game.
OK, how its used: (off the top of my head)

first seed the random number generator:
srand(Time(NULL));
next, get a random number from 0 to, say 51
int RandomNumber;
RandomNumber = rand()&52;
thats it, you now have a random number

2007-01-06 00:55:08 · answer #1 · answered by justme 7 · 0 0

Couldn't you use rand to pick a number from 1-52, then assign each value to a card in a deck of cards? That would allow you to deal the cards. At that point, you could do a simple blackjack game?

2007-01-06 01:24:53 · answer #2 · answered by geek49203 6 · 0 0

See the man page for rand(3). Just type

man rand()

into Yahoo or Google.

2007-01-06 01:08:37 · answer #3 · answered by Mark H 4 · 0 1

fedest.com, questions and answers