1 / 4

Bingo Example: Design (Print Card Algorithm)

Bingo Example: Design (Print Card Algorithm). J. Michael Moore CSCE 121. Design. Console constrains output to characters only. Use a 2D (2 dimensional) homogeneous compound data structure that we can index into (e.g. an array or vector)

careyj
Download Presentation

Bingo Example: Design (Print Card Algorithm)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Bingo Example:Design(Print Card Algorithm) J. Michael Moore CSCE 121

  2. Design • Console constrains output to characters only. • Use a 2D (2 dimensional) homogeneous compound data structure that we can index into (e.g. an array or vector) • Recall that most homogeneous compound data structures in computers have zero based indexes.

  3. Design • We want to store numbers, but how to represent the free spot? • Use a negative value • Largest number is 2 digits so use 2 places for all numbers • Space between each column • Console uses monospaced fonts so alignment works with just spaces • Note that if we prepend a space to the first column each column is 3 characters wide including the space in the front. • Example output B I N G O 5 29 42 52 68 14 17 38 60 75 7 22 F 49 62 13 28 33 46 63 3 27 32 54 73

  4. Overall • Fill card with values (we’ll see later) • Print Column Labels (i.e. BINGO) • Print the values where each letter is right justified with 3 spaces • Print values (use row major order) • For each row (values 0-4) • For each col (values 0-4) • Output card[row][col] right justified with 3 spaces • New line

More Related