12990 - Bingo Game   

Description

 

Amazon.com: Bingo Adventure - Best Free Bingo Game!: Appstore for Android

 

Bingo is a game of chance in which each player matches numbers printed in different arrangements on cards with the numbers the game host (caller) draws at random, marking the selected numbers with tiles. When a player finds the selected numbers are arranged on their card in a row, they call out "Bingo!"

 

Due: 26th November, 2020 (Thursday), 23:59

NOTE: This problem is only open for the purposes of DEBUGGING your project. Your final result must be submitted to the elearn website.

Instructions 

  1. Submit your source file (.c file) to elearn.nthu.edu.tw.  Your filename should contain your student ID.

  2. Due to the tight schedules, it is impossible to postpone the due date of an assignment.  For late assignments, 20% of your original marks will be deducted if you hand in 1- day late, 40% for 2-day, 60% for 3-day and 80% for 4-day. Assignments handed in 5  days after the due date will not be accepted.

 

Task Description 

In this assignment, you are to write a program to help a player play the game Bingo. In  our version of Bingo, each player is given a card containing an nxn array of numbers.  The numbers are in the range 0 to 99 and will not repeat. An example of a 5x5 array is  shown below. 

Then the referee will randomly select a number from 0 to 99 and each player will search  for the number in his array. If the number is present, he will mark it off. This is repeated  until some player has a complete row, column or diagonal marked off. That player will  then declare himself a winner and the game is stopped. For example, suppose the  sequence of numbers chosen by the referee is: 

12, 99, 70, 23, 49, 21, 1, 50, 7, 88, 17, 45, 97, 65, 33. Then the player holding the above card will mark the corresponding entries on his table : 

As soon as he marks off the number 33, he has a diagonal and a row completed.  Therefore, he declares himself a winner. Notice that some numbers (e.g., 70 and 23) in  the sequence are not present in the table. 

Suppose on the other hand, the sequence of numbers is: 

12, 99, 70, 23, 49, 21, 1, 50, 7, 88, 17, 45, 97 when some other player has completed a row/column/diagonal, the game is stopped.  

Your program will input an integer n in the range 0 to 99. This represents the number of  rows and also the number of columns of the table. This is followed by n lines of integers,  each line containing n integers. This represents the nxn table. Finally, there will be a  sequence of integers in the range 0 to 99 followed by a -1 value, each value on a separate  line. You may assume that the numbers in the sequence do not repeat and that the  sequence of numbers will be ended (with a -1) as soon as a row, column or diagonal is  completed. A sample input is given below. 

Your program will then output “won\n” or “lost\n” depending on whether the player holding  the card wins on that sequence or not. Then output the table and mark the numbers with  star(s) in the row/column/diagonal that is completely matched. Notice that in the sample  output below, the numbers 17, 1 and 88 are not marked because they are not involved in a  completed row, column or diagonals. 

Your table should have n columns and n rows. Each column is 3-character wide and  there should be 1 blank space between two columns. Column 1 should start in the left  margin. If a number should be marked, put enough stars (*) in front of the number so  that the stars and the number together is 3-character wide.

Input

  • First input, N, is the size of the NxN array.
  • Next N lines will be the elements of the array.
  • Followed by the game numbers, terminated by -1.
  • (However, if the entered numbers meet the "won" condition, the program must be stopped immediately and output the result, even though "-1" has not been entered.)

Output

  • First line should display "won\n" or "lost\n"
  • Followed by an NxN array, with the marked elements.
  • Attention:No blank(space) at the end of each line.

 

Sample Input  Download

Sample Output  Download

Tags




Discuss