Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int random_var(void);
- int main(void)
- {
- int numHEAD = 0, numTAIL = 0, cointoss, numGAME, round = 1;
- printf("Enter the number of games you wish to play: ");
- scanf("%d", &numGAME);
- srand((unsigned) time(NULL));
- while (round <= numGAME)
- {
- while (numHEAD < 20 || numTAIL < 20)
- {
- cointoss = random_var();
- printf("%dn", cointoss);
- if (cointoss == HEAD)
- numHEAD++;
- if (cointoss == TAIL)
- numTAIL++;
- }
- if (numHEAD == 20)
- printf("Game Tries/Game Eventn%-4d %d %d HEADsn", round, numHEAD + numTAIL, numHEAD);
- if (numTAIL == 20)
- printf("Game Tries/Game Eventn%-4d %d %d TAILsn", round, numHEAD + numTAIL, numTAIL);
- round++;
- }
- return 0;
- }
- int random_var(void)
- {
- return rand() % 2;
- }
- while (round <= numGAME) {
- int numHEAD = 0, numTAIL = 0;
- ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement