-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandom.h
More file actions
31 lines (26 loc) · 993 Bytes
/
Random.h
File metadata and controls
31 lines (26 loc) · 993 Bytes
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
#ifndef RANDOM_H_
#define RANDOM_H_
// Random class
// This code assumes 32-bit ints,
// which are standard on modern compilers.
//
// CONSTRUCTION: with (a) no initializer or (b) an integer
// that specifies the initial state of the generator
//
// ******************PUBLIC OPERATIONS*********************
// Return a random number according to some distribution:
// int randomInt( ) --> Uniform, 1 to 2^31-1
// int random0_1( ) --> Uniform, 0 to 1
// int randomInt( int low, int high ) --> Uniform low..high
class Random
{
public:
explicit Random( int initialValue = 1 );
int randomInt( );
int randomIntWRONG( );
double random0_1( );
int randomInt( int low, int high );
private:
int state;
};
#endif