1994-09-04 04:03:31 +00:00
|
|
|
/* rnd.c - version 1.0.2 */
|
1999-11-16 02:45:03 +00:00
|
|
|
/* $FreeBSD$ */
|
1994-09-04 04:03:31 +00:00
|
|
|
|
1997-09-24 05:18:42 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#define RND(x) (random() % x)
|
1994-09-04 04:03:31 +00:00
|
|
|
|
|
|
|
rn1(x,y)
|
1999-11-16 02:58:06 +00:00
|
|
|
x,y;
|
1994-09-04 04:03:31 +00:00
|
|
|
{
|
|
|
|
return(RND(x)+y);
|
|
|
|
}
|
|
|
|
|
|
|
|
rn2(x)
|
1999-11-16 02:58:06 +00:00
|
|
|
x;
|
1994-09-04 04:03:31 +00:00
|
|
|
{
|
|
|
|
return(RND(x));
|
|
|
|
}
|
|
|
|
|
|
|
|
rnd(x)
|
1999-11-16 02:58:06 +00:00
|
|
|
x;
|
1994-09-04 04:03:31 +00:00
|
|
|
{
|
|
|
|
return(RND(x)+1);
|
|
|
|
}
|
|
|
|
|
|
|
|
d(n,x)
|
1999-11-16 02:58:06 +00:00
|
|
|
n,x;
|
1994-09-04 04:03:31 +00:00
|
|
|
{
|
1999-11-16 02:58:06 +00:00
|
|
|
tmp = n;
|
1994-09-04 04:03:31 +00:00
|
|
|
|
|
|
|
while(n--) tmp += RND(x);
|
|
|
|
return(tmp);
|
|
|
|
}
|