Article View: comp.sys.amiga.tech
Article #7186rand() within a range.
From: David Thiele
Date: Mon, 03 Dec 1990 23:20
Date: Mon, 03 Dec 1990 23:20
21 lines
739 bytes
739 bytes
Is there a way to generate random numbers within a certain range in
Lattice C??. Ive done it with the following code but it's not very
elegant (or fast!),
Random(range,seed)
int range,seed;
{
srand(seed);
if range = 0
return(0);
else{
do
seed = rand() / 10000000;
while (seed >= range);
return(seed);
}
}
urrgghh! help
Dave
Technical Details
Message-ID:
<666@sheoak.bcae.oz>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!munnari.oz.au!goanna!sheoak!737104Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!munnari.oz.au!goanna!sheoak!737104 From: 737104@sheoak.bcae.oz (David Thiele) Newsgroups: comp.sys.amiga.tech Subject: rand() within a range. Message-ID: <666@sheoak.bcae.oz> Date: 3 Dec 90 23:20:23 GMT Reply-To: 737104@sheoak.bcae.oz (David Thiele) Organization: Student Stress Centre Lines: 21