1 / 8

nested loop to initiate Bingo board

nested loop to initiate Bingo board. START. k = 0;. for i =1:5. 0. 1. 0. for j =1:15. 1. k = k + 1;. board( j,i )= k;. called( j,i )= 0;. END. pick a “ball” from the Bingo board. START. pick = 0;. 0. while pick == 0. 1. pick_col = ceil(rand ()*5);.

africa
Télécharger la présentation

nested loop to initiate Bingo board

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. nested loop to initiate Bingo board START k = 0; for i=1:5 0 1 0 for j=1:15 1 k = k + 1; board(j,i)=k; called(j,i)=0; END

  2. pick a “ball” from the Bingo board START pick = 0; 0 while pick == 0 1 pick_col = ceil(rand()*5); pick_row = ceil(rand()*15); number = board(pick_row, pick_col); if called(pick_row,pick_col) == 0 0 1 called(pick_row,pick_col)=number; pick = 1; END count = count + 1;

  3. check user response Y or N START response = 1; while response 0 1 check=input('Y/N\n','s'); 1 if check==Y|N 0 invalid input response = 0; END

  4. Nerd Bingo Card Generator DATA START READ 0 for k=1:n 1 ZEROS FILL PRINT END

  5. aiche.txt START members = textread() read member names n = size(members) READ names = strvcat(members) END

  6. fill card with zeros START ZEROS 0 for i=1:5 1 i=i+1 for j=1:5 0 1 j=j+1 card(j,i)=0 END card = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

  7. fill card with numbers FILL START bingo = 0; 0 for i=1:5 1 i=i+1 PRINT bingo = bingo + 15 for j=1:5 0 1 j=j+1 NMSU AIChE Student Chapter Official Nerd Bingo Card B I N G O 5 21 43 52 65 3 23 41 46 74 14 18 37 50 68 12 25 32 59 69 7 16 33 58 70 Polly Darton -------- cut here -------- PICK END

  8. place a number in position (i,j) without repetition START number = 1; PICK while number 0 1 number = bingo + ceil(rand()*15); if sum(card(:)==number)==0 0 1 card(i,j) = number; number = 0; END

More Related