/****************************************************************************** * This program generates random floats, one per line. * * Copyright © 2020 Richard Lesh. All rights reserved. *****************************************************************************/ #undef NDEBUG #include "Utils.hpp" #include #include #include #include #include #include std::locale utf8loc(std::locale(), new std::codecvt_utf8); using namespace std; int main(int argc, char **argv) { setlocale(LC_ALL, "en_US.UTF-8"); wcout.imbue(utf8loc); wcin.imbue(utf8loc); if (argc != 4) { wcout << L"Syntax: " << Utils::UTF8_to_wstring(argv[0]) << L" min max count" << endl; exit(1); } double min = Utils::stodWithDefault(Utils::UTF8_to_wstring(argv[1]), 0); double max = Utils::stodWithDefault(Utils::UTF8_to_wstring(argv[2]), 0); int count = Utils::stoiWithDefault(Utils::UTF8_to_wstring(argv[3]), 0); double diff = max - min; srand(time(0)); double x; for (int i = 0; i < count; ++i) { x = min + rand()/(RAND_MAX + 1.0) * diff; wcout << x << endl; } return 0; }