Quzah:
I think his problem was that when he wants to randomly generate a card to deal to a player, it might sometimes generate the same card.
Quzah:
I think his problem was that when he wants to randomly generate a card to deal to a player, it might sometimes generate the same card.
Environment: OS X, GCC / G++
Codes: Java, C#, C/C++
AOL IM: neandrake, Email: neandrake (at) gmail (dot) com
That's why I said if you start with an array numbered 0 through 52 and shuffle it ...
You know, something like that...Code:for( x = 0; x < 100000; x++ ) { int one, two, bucklemyshoe; one = rand() % 52; two = rand() % 52; bucklemyshoe = deck[ one ]; deck[ one ] = deck[ two ]; deck[ two ] = bucklemyshoe; }
Quzah.
Hope is the first step on the road to disappointment.
In C++, you could simply use std::random_shuffle.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law