I think you can use this:timeGetTime()+rand()%13system will join when you generation digital and number will depend on when you push the button.Millisecond is very quick and you can't control it.This is my original.
I use timeGetTime(), but sometimes I get the same card twice and I dont want it to happen. I need first to make all the cards in the deck, and then do random_shaffle but I dont know how :(
I suppose there's no point re-inventing the wheel; if random_shuffle does the job, you may as well use it.
In a more primitive environment, I use this method to avoid duplicates.
First, select an item randomly from the array.
Then, if it happens that this is the last item, simply reduce the size of the array by one and adjust the random-number generator range accordingly.
Or if it is not the last item (most likely), copy the very last item into the position of the selected item. And reduce the size of the array and the random-number generator range by one.
Repeat until the array is empty.
(actually, you don't need to change the array size. Simply reducing the range of the random numbers until it is zero will work).
use bool a[4][13]to record what card you choosed and if card is duolicate,choose next card.If next card is duolicate too,choose next card's next card and so on.