Advertisement

General Programming Questions

Started by January 02, 2002 07:05 PM
2 comments, last by antix 23 years, 1 month ago
1. How does a computer''s switch-based modus operandi allow for the creation of random numbers? 2. What is the "best" way to shuffle/deal a deck of cards (using C++)?
What''s this got to do with OpenGL?
Advertisement
modulus is an operator that shows the remainder of the number
5 % 4 = 1
using somthing like rand()%10 limits the random number from going past 10

By the way...people get cranky if you post a question in the wrong place. Be careful next time.
good luck

The nightmare travels across the cosmos with his burning mane. The trail of ash that is produced.

?Have a nice day!?

I''m angry as hell, but I''m gonna help you anyway.

Please note that due to my anger this might not be the best way.

1) Number the cards 1-52
2) Fill an array (bool array) with 52 elements with false
3) Make a new array (the ''deck'')
4) Choose a card and put it into the ''deck'', setting the ''card'' flag to true (in step 2''s array)
5) If the card was already used (i.e. the step-2 array element was true), choose another card w/o putting it into the deck
6) Repeat with step 4 until all 52 cards are happy

p.s. I''m actually not angry.

This topic is closed to new replies.

Advertisement