#include <iostream>
#include <cstdlib>
#include <ctime>
/**
* In a game you may choose out of three options.
* One of the three contains a price, the others nothing
* After you choosed one, the moderator opens one of the others - an empty one, and asks you if you want to change your mind.
* What would you do: keep you current choice, or take the other one.
*
* You are allowed to create a program to calculate your changes :-)
* Please do that below
*/
int main()
{
srand(time(nullptr));
int N_keeper = 0;
int N_changer= 0;
for ( int i = 0; i < 10; ++i )
{
int a1 = rand() % 3; // position of the price
int a2 = rand() % 3; // your choice
int a3 = rand() % 3; // moderator action
while ( a3 == a1 || a3 == a2 )
{
a3 = rand() % 3;
}
std::cout("Price in "<<a1<<". Your choice is "<<a2<<". Moderator opens "<<a3<<std::endl;
if ( a1 == a2 )
{
N_keeper++;
}
if ( a1 != a2 )
{
N_changer++;
}
}
std::cout<<"Keeping your choice gives "<<N_keeper<<" prices out of 100"<<std::endl;
std::cout<<"Changing your mind gives "<<N_changer<<" prices out of 100"<<std::endl;
return 0;
}