home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_09_02
/
9n02038a
< prev
next >
Wrap
Text File
|
1990-11-11
|
479b
|
32 lines
Listing 3.
/* random.c */
#define SL_RAND_MAX 32767
static long next = 1;
unsigned slrand()
{
next = next * 1103515245 + 12345;
return((unsigned int) ((next / 65536) % 32768));
}
slsrand(seed)
unsigned seed;
{
next = seed;
}
/* return a random number in the range 0 .. (limit - 1) */
int slrandom(limit)
unsigned limit;
{
long num;
num = (long) slrand();
return((int) ((num * limit) / (1L + SL_RAND_MAX)));
}