i am creating a shuffling system for a card game i am making for school.
i have used _card = rand() % 51;
seeing as the first card registers to 00 and the last to 51...
but i am unsure as to how to set it up to prevent a card from being selcted twice. I have confirmed it randomizes properly but i am just stuck on controlling the possibility of repeat cards
store an array of 52 booleans to store whether each card has been drawn before? Or when a card is selected add it to a list or vector or something then when selecting the next random card check the list to see if it has already been chosen, if so choose again until the chosen card is not a repeat
Disch is correct. Modulo works by diving dividing the left operand by the right operand and returning (giving you) the remainder.
A remainder of n can never equal n, or else it is not the remainder.
If I have 3 people in the room and have 3 cookies for each person, I don't have any left over ( 3 % 3 = 0 ). Unless I don't like you and cut one of your cookies in half.
std::cout << rand() % 2; // count how many 2's you get