1993-08-02 21:18:41 +04:00
|
|
|
#ifndef lint
|
1995-03-23 11:28:00 +03:00
|
|
|
static char rcsid[] = "$NetBSD: rnd.c,v 1.3 1995/03/23 08:32:28 cgd Exp $";
|
1993-08-02 21:18:41 +04:00
|
|
|
#endif /* not lint */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
#define RND(x) ((random()>>3) % x)
|
|
|
|
|
|
|
|
rn1(x,y)
|
|
|
|
register x,y;
|
|
|
|
{
|
|
|
|
return(RND(x)+y);
|
|
|
|
}
|
|
|
|
|
|
|
|
rn2(x)
|
|
|
|
register x;
|
|
|
|
{
|
|
|
|
return(RND(x));
|
|
|
|
}
|
|
|
|
|
|
|
|
rnd(x)
|
|
|
|
register x;
|
|
|
|
{
|
|
|
|
return(RND(x)+1);
|
|
|
|
}
|
|
|
|
|
|
|
|
d(n,x)
|
|
|
|
register n,x;
|
|
|
|
{
|
|
|
|
register tmp = n;
|
|
|
|
|
|
|
|
while(n--) tmp += RND(x);
|
|
|
|
return(tmp);
|
|
|
|
}
|