1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| // bernoulli_distribution example: fortune-teller #include <iostream> #include <string> #include <random> int main() { std::cout << "Please, enter a yes/no question (I will answer it):" << std::endl; std::string text; getline(std::cin,text); std::seed_seq seed (text.begin(),text.end()); // seed using question std::default_random_engine generator (seed); std::bernoulli_distribution distribution(0.5); bool result = distribution(generator); std::cout << ( result ? "yes" : "no" ) << std::endl; return 0; }
|