-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.cpp
60 lines (51 loc) · 1.9 KB
/
example.cpp
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "MTEngine.hpp"
#include "PrintUtils/PrintUtils.hpp"
#include <vector>
#include <iostream>
/**
* This is the main function where the execution of the program begins.
*/
int main()
{
/**
* An instance of the MTEngine class is created.
* The MTEngine class is a pseudorandom number generator,
* based on the Mersenne Twister algorithm.
*/
MTEngine engine;
/**
* The rand() function of the MTEngine class is called to generate a random number.
* The generated number is then printed to the console.
*/
std::cout << engine.rand() << std::endl;
/**
* The choice() function of the MTEngine class is called with three arguments: 1, 2, and 3.
* This function is assumed to randomly select and return one of the provided arguments.
* The selected number is then printed to the console.
*/
std::cout << engine.choice(1, 2, 3) << std::endl;
/**
* A vector of doubles is created with the values 1, 2, 3, 4, and 5.
*/
std::vector<double> v = {1, 2, 3, 4, 5};
/**
* The Shuffle() function of the MTEngine class is called with the vector as an argument.
* This function is assumed to randomly rearrange the elements in the provided vector.
*/
engine.Shuffle(v);
/**
* The contents of the vector are printed to the console.
* an overloaded operator<< for vectors from PrintUtils.hpp is used to print the vector.
*/
std::cout << v << std::endl;
/**
* The Choice() function of the MTEngine class is called with 15 arguments.
* This function is assumed to randomly select and return one of the provided arguments.
* The selected number is then printed to the console.
*/
std::cout<<engine.Choice(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)<<std::endl;
/**
* The main function returns 0, indicating successful execution of the program.
*/
return 0;
}