Home | History | Annotate | Line # | Download | only in hack
rnd.c revision 1.2
      1  1.2  mycroft #ifndef lint
      2  1.2  mycroft static char rcsid[] = "$Id: rnd.c,v 1.2 1993/08/02 17:19:45 mycroft Exp $";
      3  1.2  mycroft #endif /* not lint */
      4  1.1      cgd 
      5  1.1      cgd #define RND(x)	((random()>>3) % x)
      6  1.1      cgd 
      7  1.1      cgd rn1(x,y)
      8  1.1      cgd register x,y;
      9  1.1      cgd {
     10  1.1      cgd 	return(RND(x)+y);
     11  1.1      cgd }
     12  1.1      cgd 
     13  1.1      cgd rn2(x)
     14  1.1      cgd register x;
     15  1.1      cgd {
     16  1.1      cgd 	return(RND(x));
     17  1.1      cgd }
     18  1.1      cgd 
     19  1.1      cgd rnd(x)
     20  1.1      cgd register x;
     21  1.1      cgd {
     22  1.1      cgd 	return(RND(x)+1);
     23  1.1      cgd }
     24  1.1      cgd 
     25  1.1      cgd d(n,x)
     26  1.1      cgd register n,x;
     27  1.1      cgd {
     28  1.1      cgd 	register tmp = n;
     29  1.1      cgd 
     30  1.1      cgd 	while(n--) tmp += RND(x);
     31  1.1      cgd 	return(tmp);
     32  1.1      cgd }
     33