fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. int main(void) {
  6. int i = 0;
  7. const int NUM_PLAYERS = 5;
  8. int Bingo[NUM_PLAYERS] ;
  9. int cardDisplay[5][5];
  10. int j;
  11. int cardsperPlayer;
  12. int bingoCards;
  13. int optionSelect;
  14. int firstCard;
  15. int lastCard;
  16.  
  17.  
  18.  
  19. printf("Enter number of players:\n");
  20. scanf("%d", &Bingo[i]);
  21. printf("Enter the number of BINGO cards per player:\n");
  22. scanf("%d", &cardsperPlayer);
  23. bingoCards = cardsperPlayer * Bingo[i];
  24. printf("You are now playing with %d players and each player will have %d cards\n", Bingo[i], cardsperPlayer);
  25. printf("We have generated %d bingo cards.\n", bingoCards);
  26. printf("Please choose an option from the following menu:\n");
  27. printf("1) Display a bingo card \n");
  28. printf("2) run a histogram across all bingo cards generated \n");
  29. printf("3) exit\n");
  30. scanf("%d", &optionSelect);
  31. printf("You have chosen %d\n", optionSelect);
  32. int upper = 15;
  33. int lower = 1;
  34. printf("First card is %d, last card is %d\n", firstCard, lastCard);
  35. printf(" B I N G O \n");
  36. for (i = 0; i < 5; i++) {
  37. for (j = 0; j < 5; j++){
  38. cardDisplay[j][i] = (rand() % upper)+lower;
  39. }
  40. lower+=15;
  41. }
  42. if (optionSelect == 1) {
  43. printf("Enter the player and players card you would like to display,\n");
  44. scanf("%d", &Bingo[i]);
  45. printf("First player is %d,", Bingo[i]);
  46. scanf("%d", &Bingo[i]);
  47. printf(" last player is %d\n", Bingo[i]);
  48. scanf("%d", &firstCard);
  49. scanf("%d", &lastCard);
  50. for (i = 0; i < 5; i++) {
  51. for (j = 0; j < 5; j++){
  52. printf("%c", cardDisplay[j][i]);
  53. }
  54. }
  55. }
  56. while (optionSelect != 3) {
  57. printf("You have chosen %d", optionSelect);
  58. optionSelect = 3;
  59. }
  60. return 0;
  61. }
  62.  
  63.  
  64.  
Success #stdin #stdout 0s 9432KB
stdin
4
10
3
stdout
Enter number of players:
Enter the number of BINGO cards per player:
You are now playing with 4 players and each player will have 10 cards
We have generated 40 bingo cards.
Please choose an option from the following menu:
1) Display a bingo card 
2) run a histogram across all bingo cards generated 
3) exit
You have chosen 3
First card is -529643776, last card is 11077
 B  I  N  G  O