Create a puzzle of guessing game of three boxes in which a player could win a prize by guessing the right box that the prize was behind. One player choose one box, and the game virtual assistant opens one of the other box that does not have the prize behind it. At that point in the game, the player has the option of changing his choice to the third box to win the prize. This game can be demonstrate using conditional probabilities.
#include <iostream>
#include <stdlib.h>
#include <ctime>
Using namespace std;
int main() {
Into b;
cout<< "Enter your number"<<endl;
cin>>b;
srand((unsigned) time(0));
Cout<<" playing "<<endl;
int result = 1 + (rand() % 3);
if(b==result){
Cout<<"you won"<<endl;
}else{
Cout<<"lost"<<endl;
}
}
}
Comments
Leave a comment