Advertisement
Vlad3955

Untitled

Sep 28th, 2021
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1.  
  2.  
  3. #include <iostream>
  4. #include <cmath>
  5. #include <ctime>
  6. #include <cstdlib>
  7. #include <random>
  8.  
  9. using namespace std;
  10.  
  11. double p, p1, p2;
  12.  
  13.  
  14. void bomb() {
  15.     p = 1 - pow(1 - (1 - p1) * p2, 2);
  16.     for (int i = 0; i < 10; i++)
  17.     {
  18.         if (p <= 0.8) {
  19.             cout << "P: " << p << endl;
  20.             cout << "p1: " << p1 << endl;
  21.             cout << "p2: " << p2 << endl;
  22.         }
  23.     }
  24.    
  25. }
  26.  
  27.  
  28. int main() {
  29.     /*random_device rd;
  30.     mt19937 mersenne(0.0);
  31.     for (double i = mersenne(); i <= 1.0; i++) {
  32.         p1 = i;
  33.        
  34.     }
  35.     for (double i = mersenne(); i <= 1.0; i++) {
  36.         p2 = i;
  37.        
  38.     }*/
  39.     for (int i = 0; i < 10; i++) {
  40.         double min, max;
  41.         min = 0.0;
  42.         max = 1.0;
  43.         p1 = (double)rand() / (double)RAND_MAX * (max - min) + min;
  44.         //p2 = (double)rand() / (double) RAND_MAX * (max - min) + min;
  45.     }
  46.  
  47.     for (int i = 0; i < 10; i++) {
  48.         double min1, max2;
  49.         min1 = 0.0;
  50.         max2 = 1.0;
  51.         p1 = (double)rand() / (double)RAND_MAX * (max2 - min1) + min1;
  52.     }
  53.     bomb();
  54.    
  55.         return 0;
  56.    
  57.     cout << p << p1 << p2 << endl;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement