Monty Hall problem: Difference between revisions
Content deleted Content added
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 |
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); |