Computer Science Canada Random Generation of cards (total in deck 40) |
Author: | xHoly-Divinity [ Thu Dec 02, 2004 4:21 pm ] | ||
Post subject: | Random Generation of cards (total in deck 40) | ||
Our assignment is to create a program (using procedures, for loops, and 2 dimensional arrays) that will randomly draw cards from a deck. Once a card is selected, that same card cannot be drawn again. After all 40 cards have been processed, then the program terminates. So far I've only gotten the drawings of all four suites using procedures. I have no idea where to go from there!!! I really need some help!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
Author: | SuperGenius [ Thu Dec 02, 2004 7:25 pm ] | ||
Post subject: | |||
What you'll want to do is have a 2d array. At the start of the pram have two for loops and set every element in the array to 0. Then you'll need two random integers to select a card. If the array element that corresponds to that number is 0, then say "ok this is the card", and then set that particular element to 1. You're going to have to put this code inside a structure that says
as well you will have to check that you've got a valid card selected before you can exit this structure. |