Impl generating random value

This commit is contained in:
Stephen Seo 2020-10-29 22:03:26 +09:00
parent b72fdd0cfe
commit 14b605e8a1
3 changed files with 57 additions and 1 deletions

6
.gitignore vendored Normal file
View file

@ -0,0 +1,6 @@
KoreanNumbers
src/*.o
compile_commands.commands.json
compile_commands.json
.clangd/

View file

@ -1,4 +1,4 @@
COMMON_CXXFLAGS = -Wall -Wextra -Wpedantic COMMON_CXXFLAGS = -Wall -Wextra -Wpedantic -std=c++20
ifdef DEBUG ifdef DEBUG
CXXFLAGS = -O0 -g ${COMMON_CXXFLAGS} CXXFLAGS = -O0 -g ${COMMON_CXXFLAGS}
else else

View file

@ -1,3 +1,53 @@
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <random>
#include <chrono>
#include <memory>
#include <string>
#include <iostream>
const wchar_t* won = L"";
const wchar_t* ship = L"";
const wchar_t* bec = L"";
const wchar_t* chun = L"";
const wchar_t* man = L"";
const wchar_t* uc = L"";
void help() {
puts("Usage:");
puts(" --max <integer> - set maximum value for generated value (default 999,999,999,999)");
}
std::wstring value_to_korean(unsigned long long value) {
return L"UNIMPLEMENTED";
}
int main(int argc, char **argv) { int main(int argc, char **argv) {
unsigned long long max = 999999999999;
--argc; ++argv;
while(argc > 0) {
if(std::strcmp(argv[0], "--max") == 0 && argc > 1) {
--argc; ++argv;
max = std::strtoull(argv[0], nullptr, 0);
}
--argc; ++argv;
}
printf("Maximum value is set to %llu\n", max);
unsigned long long value;
{
std::default_random_engine r_eng(std::chrono::steady_clock::now().time_since_epoch().count());
std::uniform_int_distribution<unsigned long long> r_dist(0, max);
value = r_dist(r_eng);
}
printf("\nGot value \"%llu\", hit enter to continue...", value);
std::cin.get();
std::wcout << "Result: " << value_to_korean(value) << std::endl;
return 0; return 0;
} }