Monty Hall problem: Difference between revisions

Content added Content deleted
Line 414: Line 414:


//if the next door has a goat, and the following door has a car, or vice versa, you'd win if you switch.
//if the next door has a goat, and the following door has a car, or vice versa, you'd win if you switch.
if(((!(door[((choice+1)%3)])) && (door[((choice+2)%3)])) || (!(door[((choice+2)%3)]) && (door[((choice+1)%3)]))) winsbyswitch++;
if((!(door[((choice+1)%3)]) && (door[((choice+2)%3)])) || (!(door[((choice+2)%3)]) && (door[((choice+1)%3)]))) winsbyswitch++;
}
}
printf("\nAfter %u games, I won %u by switching. That is %f%%. ", GAMES, winsbyswitch, (float)winsbyswitch*100.0/(float)i);
printf("\nAfter %u games, I won %u by switching. That is %f%%. ", GAMES, winsbyswitch, (float)winsbyswitch*100.0/(float)i);