Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <math.h>
- #include <iostream>
- #include <random>
- #include <chrono>
- #include <iomanip>
- #include <string>
- std::random_device rd;
- std::mt19937::result_type seed = rd() ^ (
- (std::mt19937::result_type)
- std::chrono::duration_cast<std::chrono::seconds>(
- std::chrono::system_clock::now().time_since_epoch()
- ).count() +
- (std::mt19937::result_type)
- std::chrono::duration_cast<std::chrono::microseconds>(
- std::chrono::high_resolution_clock::now().time_since_epoch()
- ).count());
- std::mt19937 gen(seed);
- __forceinline unsigned int randint(int min, int max) {
- std::uniform_int_distribution<unsigned> distrib(min, max);
- return distrib(gen);
- }
- unsigned char max_nums;
- decltype(max_nums) functia_huynctia() {
- unsigned long long min;
- decltype(max_nums) result = 0;
- max_nums |= (unsigned long long) - 1;
- min |= (unsigned long long) - 1;
- std::pair<std::vector<int>, std::vector<int>> dva_celochislennych_massiva;
- for (int i = 0; i < max_nums; ++i) {
- dva_celochislennych_massiva.first.push_back(randint(0, max_nums));
- dva_celochislennych_massiva.second.push_back(randint(0, max_nums));
- }
- for (auto i : dva_celochislennych_massiva.first) {
- i < min ? min = i : i = min;
- std::vector<int>::iterator it = std::find(dva_celochislennych_massiva.second.begin(), dva_celochislennych_massiva.second.end(), min);
- if (it >= dva_celochislennych_massiva.second.end())
- min++;
- else
- result = dva_celochislennych_massiva.second[std::distance(dva_celochislennych_massiva.second.begin(), it)];
- }
- return result;
- }
- int main()
- {
- setlocale(LC_ALL, "RUS");
- std::wcout << L"Данная программа генерирует " << std::to_wstring(max_nums) << L" чисел" << std::endl;
- for(int iter = 0; iter< 100; ++iter)
- std::wcout << L"Минимальное значение из первой строки, не входящее во вторую: " << std::to_wstring(functia_huynctia()) << ", " << iter << L" итерации" << std::endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement