Axeer

pz3_1

Oct 19th, 2021 (edited)
474
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.96 KB | None | 0 0
  1. #include <math.h>
  2. #include <iostream>
  3. #include <random>
  4. #include <chrono>
  5. #include <iomanip>
  6. #include <string>
  7.  
  8. std::random_device rd;
  9. std::mt19937::result_type seed = rd() ^ (
  10.     (std::mt19937::result_type)
  11.     std::chrono::duration_cast<std::chrono::seconds>(
  12.         std::chrono::system_clock::now().time_since_epoch()
  13.         ).count() +
  14.     (std::mt19937::result_type)
  15.     std::chrono::duration_cast<std::chrono::microseconds>(
  16.         std::chrono::high_resolution_clock::now().time_since_epoch()
  17.         ).count());
  18. std::mt19937 gen(seed);
  19.  
  20. __forceinline unsigned int randint(int min, int max) {
  21.     std::uniform_int_distribution<unsigned> distrib(min, max);
  22.     return distrib(gen);
  23. }
  24.  
  25. int main()
  26. {
  27.     setlocale(LC_ALL, "RUS");
  28.  
  29.     unsigned char max_nums;
  30.     max_nums |= (unsigned long long) - 1;
  31.  
  32.     std::vector<float>arr_more_zero;
  33.     std::vector<float>arr_less_zero;
  34.     std::vector<std::wstring>sorted_out;
  35.  
  36.     for (int i = 0; i < max_nums; ++i) {
  37.         float buf = cos(randint(180, 360));
  38.         if (buf > 0)
  39.             arr_more_zero.push_back(buf);
  40.         else
  41.             arr_less_zero.push_back(buf);
  42.        
  43.     }
  44.     std::sort(arr_more_zero.begin(), arr_more_zero.end(), std::less <float>());
  45.     std::sort(arr_less_zero.begin(), arr_less_zero.end(), std::greater<float>());
  46.     for (int i = 0; i < max_nums; ++i)
  47.         if (arr_less_zero.size() > 1 and arr_more_zero.size() > 1) {
  48.             sorted_out.push_back(std::wstring(L"Случайное положительное: ")
  49.                 + std::wstring(std::to_wstring(arr_more_zero[arr_more_zero.size() - 1]))
  50.                 + std::wstring(L" Случайное отрицательное : ") + std::wstring(std::to_wstring(arr_less_zero[arr_less_zero.size() - 1])));
  51.             arr_less_zero.pop_back(); arr_more_zero.pop_back();
  52.         }
  53.     for (auto i : sorted_out)
  54.         std::wcout << i << std::endl;
  55. }
  56.                                                 Это пиздец блядь!!!
Add Comment
Please, Sign In to add comment