Advertisement
bigdaddytsotne

17//

Dec 6th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <vector>
  2. #include <random>
  3. #include <ctime>
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8.  
  9. bool lessThenX(double a)
  10. {
  11. return a < 64.5;
  12. }
  13.  
  14. void task17()
  15. {
  16. vector<double> vec1;
  17.  
  18. default_random_engine dre(time(NULL));
  19. uniform_real_distribution<double> rand(0.1, 100.2);
  20.  
  21. for (size_t i = 0; i < 95; i++)
  22. {
  23. vec1.push_back(rand(dre));
  24. }
  25.  
  26.  
  27. int res = count_if(vec1.begin(), vec1.end(), lessThenX);
  28.  
  29. int res1 = count_if(vec1.begin(), vec1.end(), [](double i) {return i < 64.5; });
  30.  
  31.  
  32. cout << "Result: " << res;
  33. cout << "Result1: " << res1;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement