Created
June 25, 2020 05:13
-
-
Save emctague/a2f77e4feca796df6febdaf2ee166592 to your computer and use it in GitHub Desktop.
MHall
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
int main() { | |
srand(time(NULL)); | |
int allTries = 1000; | |
int switchWins = 0; | |
for (int i = 0; i < allTries; i++) | |
switchWins += (rand() % 3) != (rand() % 3); | |
printf(" Wins\t%% Wins\n"); | |
printf("Switch: %d\t%f%%\n", switchWins, (float)switchWins / (float)allTries * 100.f); | |
printf(" Don't: %d\t%f%%\n\n", allTries - switchWins, (float)(allTries - switchWins) / (float)allTries * 100.f); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment