Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. int random_var(void);
  2.  
  3. int main(void)
  4. {
  5. int numHEAD = 0, numTAIL = 0, cointoss, numGAME, round = 1;
  6.  
  7. printf("Enter the number of games you wish to play: ");
  8. scanf("%d", &numGAME);
  9.  
  10. srand((unsigned) time(NULL));
  11. while (round <= numGAME)
  12. {
  13.  
  14. while (numHEAD < 20 || numTAIL < 20)
  15. {
  16. cointoss = random_var();
  17. printf("%dn", cointoss);
  18. if (cointoss == HEAD)
  19. numHEAD++;
  20. if (cointoss == TAIL)
  21. numTAIL++;
  22. }
  23.  
  24. if (numHEAD == 20)
  25. printf("Game Tries/Game Eventn%-4d %d %d HEADsn", round, numHEAD + numTAIL, numHEAD);
  26. if (numTAIL == 20)
  27. printf("Game Tries/Game Eventn%-4d %d %d TAILsn", round, numHEAD + numTAIL, numTAIL);
  28.  
  29. round++;
  30. }
  31.  
  32.  
  33. return 0;
  34. }
  35.  
  36.  
  37. int random_var(void)
  38. {
  39. return rand() % 2;
  40. }
  41.  
  42. while (round <= numGAME) {
  43. int numHEAD = 0, numTAIL = 0;
  44. ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement