1 /* $NetBSD: rnd.c,v 1.4 1997/10/19 16:59:39 christos Exp $ */ 2 3 #include <sys/cdefs.h> 4 #ifndef lint 5 __RCSID("$NetBSD: rnd.c,v 1.4 1997/10/19 16:59:39 christos Exp $"); 6 #endif /* not lint */ 7 8 #include <stdlib.h> 9 #include "hack.h" 10 #include "extern.h" 11 12 #define RND(x) ((random()>>3) % x) 13 14 int 15 rn1(x, y) 16 int x, y; 17 { 18 return (RND(x) + y); 19 } 20 21 int 22 rn2(x) 23 int x; 24 { 25 return (RND(x)); 26 } 27 28 int 29 rnd(x) 30 int x; 31 { 32 return (RND(x) + 1); 33 } 34 35 int 36 d(n, x) 37 int n, x; 38 { 39 int tmp = n; 40 41 while (n--) 42 tmp += RND(x); 43 return (tmp); 44 } 45