File: rnd.c

package info (click to toggle)
bsdgames-nonfree 2.12-3
  • links: PTS
  • area: non-free
  • in suites: woody
  • size: 2,056 kB
  • ctags: 2,113
  • sloc: ansic: 29,027; sh: 1,006; makefile: 51
file content (44 lines) | stat: -rw-r--r-- 563 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*	$NetBSD: rnd.c,v 1.4 1997/10/19 16:59:39 christos Exp $	*/

#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: rnd.c,v 1.4 1997/10/19 16:59:39 christos Exp $");
#endif				/* not lint */

#include <stdlib.h>
#include "hack.h"
#include "extern.h"

#define RND(x)	((random()>>3) % x)

int
rn1(x, y)
	int             x, y;
{
	return (RND(x) + y);
}

int
rn2(x)
	int             x;
{
	return (RND(x));
}

int
rnd(x)
	int             x;
{
	return (RND(x) + 1);
}

int
d(n, x)
	int             n, x;
{
	int tmp = n;

	while (n--)
		tmp += RND(x);
	return (tmp);
}