>>12716517>The "make a deck of cards, shuffle deck, draw two random cards" doesn't make any sense to me.It makes perfect sense. It's just not very efficient or sensible thing to do.
>I'd think to select a random number between 1 and Deck Size, can't select the same number twice but that's probably not correct.Doing it exactly as stated isn't much harder.
int cards[52];
std::generate(cards, cards+52, [](){static int i=0; return i++;});
std::mt19937 mt(std::random_device{}());
std::shuffle(cards, cards+52, mt); //extra step
char suit[4][9]={"spades","diamonds","hearts","clubs"};
char face[4][6]={"Jack","Queen","King", "Ace"};
std::uniform_int_distribution<int> getrandnum(0,51);
int card1=cards[getrandnum(mt)];
int card2=cards[getrandnum(mt)];
while (card2==card1) card2=cards[getrandnum(mt)];
auto printcard=[&](int card){
if(card%13 >8)
std::cout << face[card%13 - 9];
else
std::cout<< card%13 + 2 ;
std::cout<<" of " << suit[card/13];
};
std::cout<<"Card 1 is the ";
printcard(card1);
std::cout<<"\nCard 2 is the ";
printcard(card2);
std::cout<<"\n";