Impl generating random value
This commit is contained in:
parent
b72fdd0cfe
commit
14b605e8a1
3 changed files with 57 additions and 1 deletions
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
KoreanNumbers
|
||||
src/*.o
|
||||
|
||||
compile_commands.commands.json
|
||||
compile_commands.json
|
||||
.clangd/
|
2
Makefile
2
Makefile
|
@ -1,4 +1,4 @@
|
|||
COMMON_CXXFLAGS = -Wall -Wextra -Wpedantic
|
||||
COMMON_CXXFLAGS = -Wall -Wextra -Wpedantic -std=c++20
|
||||
ifdef DEBUG
|
||||
CXXFLAGS = -O0 -g ${COMMON_CXXFLAGS}
|
||||
else
|
||||
|
|
50
src/main.cpp
50
src/main.cpp
|
@ -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) {
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue