Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // shavewhen.cpp
- #include <cstdlib>
- #include <iostream>
- #include <random>
- int main()
- {
- std::random_device rd;
- std::mt19937 mt {rd()};
- std::bernoulli_distribution when {1.0f / 30.0f};
- std::bernoulli_distribution whether_to {1.0f / 75.0f};
- bool shave {true};
- int day_count {0};
- while (!when(mt))
- {
- if (whether_to(mt)) shave = false;
- ++day_count;
- }
- std::cout << "Number of days: " << day_count << "\n" << std::endl;
- if (!shave)
- {
- std::cout << "Wait, you know what? don't even shave.\n" << std::endl;
- }
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement