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.
Printable View
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.
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.
In C++, you could simply use std::random_shuffle.