Impl setting minimum value
This commit is contained in:
parent
91eb8544a1
commit
8c36fa69f2
1 changed files with 12 additions and 2 deletions
14
src/main.cpp
14
src/main.cpp
|
@ -257,6 +257,7 @@ void printValue(unsigned long long value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
unsigned long long min = 1;
|
||||||
unsigned long long max = 9999999999999;
|
unsigned long long max = 9999999999999;
|
||||||
bool isAlt = false;
|
bool isAlt = false;
|
||||||
bool reverse = false;
|
bool reverse = false;
|
||||||
|
@ -273,20 +274,29 @@ int main(int argc, char **argv) {
|
||||||
isAlt = true;
|
isAlt = true;
|
||||||
} else if(std::strcmp(argv[0], "-r") == 0 || std::strcmp(argv[0], "--reverse") == 0) {
|
} else if(std::strcmp(argv[0], "-r") == 0 || std::strcmp(argv[0], "--reverse") == 0) {
|
||||||
reverse = true;
|
reverse = true;
|
||||||
|
} else if(std::strcmp(argv[0], "--min") == 0 && argc > 1) {
|
||||||
|
--argc; ++argv;
|
||||||
|
min = std::strtoull(argv[0], nullptr, 0);
|
||||||
}
|
}
|
||||||
--argc; ++argv;
|
--argc; ++argv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(min == 0) {
|
||||||
|
min = 1;
|
||||||
|
} else if(min > max) {
|
||||||
|
min = max;
|
||||||
|
}
|
||||||
|
|
||||||
if(isAlt) {
|
if(isAlt) {
|
||||||
printf("Using alternate Korean numbers, ");
|
printf("Using alternate Korean numbers, ");
|
||||||
if(max > 99) { max = 99; }
|
if(max > 99) { max = 99; }
|
||||||
}
|
}
|
||||||
printf("Maximum value is set to %llu\n", max);
|
printf("Min value is set to %llu, Max value is set to %llu\n", min, max);
|
||||||
|
|
||||||
unsigned long long value;
|
unsigned long long value;
|
||||||
{
|
{
|
||||||
std::default_random_engine r_eng(std::chrono::steady_clock::now().time_since_epoch().count());
|
std::default_random_engine r_eng(std::chrono::steady_clock::now().time_since_epoch().count());
|
||||||
std::uniform_int_distribution<unsigned long long> r_dist(1, max);
|
std::uniform_int_distribution<unsigned long long> r_dist(min, max);
|
||||||
value = r_dist(r_eng);
|
value = r_dist(r_eng);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue