Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <ctime>
- #include <cstdlib>
- #include <random>
- using namespace std;
- double p, p1, p2;
- void bomb() {
- p = 1 - pow(1 - (1 - p1) * p2, 2);
- for (int i = 0; i < 10; i++)
- {
- if (p <= 0.8) {
- cout << "P: " << p << endl;
- cout << "p1: " << p1 << endl;
- cout << "p2: " << p2 << endl;
- }
- }
- }
- int main() {
- /*random_device rd;
- mt19937 mersenne(0.0);
- for (double i = mersenne(); i <= 1.0; i++) {
- p1 = i;
- }
- for (double i = mersenne(); i <= 1.0; i++) {
- p2 = i;
- }*/
- for (int i = 0; i < 10; i++) {
- double min, max;
- min = 0.0;
- max = 1.0;
- p1 = (double)rand() / (double)RAND_MAX * (max - min) + min;
- //p2 = (double)rand() / (double) RAND_MAX * (max - min) + min;
- }
- for (int i = 0; i < 10; i++) {
- double min1, max2;
- min1 = 0.0;
- max2 = 1.0;
- p1 = (double)rand() / (double)RAND_MAX * (max2 - min1) + min1;
- }
- bomb();
- return 0;
- cout << p << p1 << p2 << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement