-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandom.hpp
More file actions
51 lines (49 loc) · 1.18 KB
/
Random.hpp
File metadata and controls
51 lines (49 loc) · 1.18 KB
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
#pragma once
#include <random>
#include <array>
//using namespace std;
class Random
{
public:
Random()
{
//
}
int randint(int min, int max)
{
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dist(min, max);
return dist(gen);
}
std::string randstr(int length, std::string addchars = "")
{
std::string rstr = "";
std::string strarr = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM" + addchars;
for (int i=0;i<length;i++)
{
rstr += strarr[(*this).randint(0, strarr.length())];
}
return rstr;
}
std::string choice(
std::vector<std::string> array
)
{
return array[(*this).randint(0, array.size() - 1)];
}
/*std::vector<std::string> choices(
std::vector<std::string> array,
int length
)
{
std::vector<std::string> rarray = {};
for (int i=0;i<length;i++)
{
std::vector<std::string> value = {(*this).choice(array)};
rarray.push_back(value);
}
rarray.reserve(rarray.size());
return rarray;
}*/
};