mirror of
https://github.com/aicodix/code.git
synced 2026-04-27 22:35:44 +00:00
made random seeding optional
This commit is contained in:
parent
d319189d7a
commit
2d5e782135
1 changed files with 6 additions and 2 deletions
|
|
@ -14,10 +14,14 @@ Copyright 2024 Ahmet Inan <inan@aicodix.de>
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
const int MAX_N = 128;
|
const int MAX_N = 128;
|
||||||
std::random_device rd;
|
unsigned seed = 42;
|
||||||
|
if (1) {
|
||||||
|
std::random_device rd;
|
||||||
|
seed = rd();
|
||||||
|
}
|
||||||
typedef std::default_random_engine generator;
|
typedef std::default_random_engine generator;
|
||||||
typedef std::uniform_int_distribution<int> distribution;
|
typedef std::uniform_int_distribution<int> distribution;
|
||||||
auto rand = std::bind(distribution(1, MAX_N), generator(rd()));
|
auto rand = std::bind(distribution(1, MAX_N), generator(seed));
|
||||||
int a[MAX_N], b[MAX_N], c[MAX_N], d[MAX_N], e[MAX_N], f[MAX_N], g[MAX_N];
|
int a[MAX_N], b[MAX_N], c[MAX_N], d[MAX_N], e[MAX_N], f[MAX_N], g[MAX_N];
|
||||||
CODE::MergeSort<int, MAX_N> merge_sort;
|
CODE::MergeSort<int, MAX_N> merge_sort;
|
||||||
for (int loop = 0; loop < 1000000; ++loop) {
|
for (int loop = 0; loop < 1000000; ++loop) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue