diff options
| author | WesleyR <[email protected]> | 2024-04-21 21:38:58 -0700 |
|---|---|---|
| committer | WesleyR <[email protected]> | 2024-04-21 21:38:58 -0700 |
| commit | 33c72afebeafd9f672f19502f99ffb91caf5f695 (patch) | |
| tree | 1c0a25ee87ddc504a4020df4458206110eb7ad9e /CST 126/Homework 1/getrandom.hpp | |
| parent | updates (diff) | |
| download | archived-homework-1-wesleyr23-33c72afebeafd9f672f19502f99ffb91caf5f695.tar.xz archived-homework-1-wesleyr23-33c72afebeafd9f672f19502f99ffb91caf5f695.zip | |
Submission
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 |