diff options
| author | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2021-12-27 00:00:00 +0000 |
|---|---|---|
| committer | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2022-03-18 15:35:13 +0500 |
| commit | f19f813537c7aea1c20749c914e756b54a9c3cf5 (patch) | |
| tree | 816ba62ca7c0fa19f2eb46d9e9d6f7dd7c3a744d /CPP/Common/Random.cpp | |
| parent | 98e06a519b63b81986abe76d28887f6984a7732b (diff) | |
| download | 7zip-f19f813537c7aea1c20749c914e756b54a9c3cf5.tar.gz 7zip-f19f813537c7aea1c20749c914e756b54a9c3cf5.tar.bz2 7zip-f19f813537c7aea1c20749c914e756b54a9c3cf5.zip | |
'21.07'21.07
Diffstat (limited to 'CPP/Common/Random.cpp')
| -rw-r--r-- | CPP/Common/Random.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/CPP/Common/Random.cpp b/CPP/Common/Random.cpp new file mode 100644 index 0000000..fbdb8c9 --- /dev/null +++ b/CPP/Common/Random.cpp | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | // Common/Random.cpp | ||
| 2 | |||
| 3 | #include "StdAfx.h" | ||
| 4 | |||
| 5 | #include <stdlib.h> | ||
| 6 | |||
| 7 | #ifndef _WIN32 | ||
| 8 | #include <time.h> | ||
| 9 | #else | ||
| 10 | #include "MyWindows.h" | ||
| 11 | #endif | ||
| 12 | |||
| 13 | #include "Random.h" | ||
| 14 | |||
| 15 | void CRandom::Init(unsigned int seed) { srand(seed); } | ||
| 16 | |||
| 17 | void CRandom::Init() | ||
| 18 | { | ||
| 19 | Init((unsigned int) | ||
| 20 | #ifdef _WIN32 | ||
| 21 | GetTickCount() | ||
| 22 | #else | ||
| 23 | time(NULL) | ||
| 24 | #endif | ||
| 25 | ); | ||
| 26 | } | ||
| 27 | |||
| 28 | int CRandom::Generate() const { return rand(); } | ||
