diff options
Diffstat (limited to 'CST 126/Homework 1/getrandom.hpp')
| -rw-r--r-- | CST 126/Homework 1/getrandom.hpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/CST 126/Homework 1/getrandom.hpp b/CST 126/Homework 1/getrandom.hpp new file mode 100644 index 0000000..8290d71 --- /dev/null +++ b/CST 126/Homework 1/getrandom.hpp @@ -0,0 +1,33 @@ +#ifndef GETRANDOM_H +#define GETRANDOM_H + +#include <random> + +using std::random_device; +using std::mt19937; +using std::uniform_int_distribution; + + +inline int GetRandom(const int upperbound, const int lowerbound) +{ + random_device rd; // a seed source for the random number engine + mt19937 gen(rd()); // mersenne_twister_engine seeded with rd() + uniform_int_distribution<> distrib(lowerbound, upperbound); + + + return distrib(gen); + + +} + + + + + + + + + + + +#endif
\ No newline at end of file |