Quick Question

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
#include <random>
#include <numeric>
#include <algorithm>

int main()
{
    const int NUM_CARDS = 52 ;
    const int NUM_ROUNDS = 5 ;
    // https://en.cppreference.com/w/cpp/language/static_assert
    static_assert( NUM_CARDS >= NUM_ROUNDS, "sanity check failed" ) ;

    int deck[NUM_CARDS] ; // deck of NUM_CARDS

    // fill the deck with cards numbered from 1 .. NUM_CARDS
    // https://en.cppreference.com/w/cpp/algorithm/iota
    std::iota( deck, deck+NUM_CARDS, 1 ) ;

    // shuffle the deck
    // https://en.cppreference.com/w/cpp/algorithm/random_shuffle
    // https://en.cppreference.com/w/cpp/numeric/random
    std::shuffle( deck, deck+NUM_CARDS, std::mt19937( std::random_device{}() ) ) ;

    // for each round, deal out the cards one by one from the randomly shuffled deck
    for( int n = 0 ; n < NUM_ROUNDS ; ++n )
        std::cout << "round #" << n+1 << " table card == #" << deck[n] << '\n' ;
}

http://coliru.stacked-crooked.com/a/3d984586ed451a34
Except you should better use std::array<int,NUM_CARDS> where is the question?
@Thomas Huxhorn

Actually, JLBorges was responding to a poster, but it seems this poster deleted his or her question leaving just the hint of a solution.
Oh okay.
Indeed a very quick question ;)
Topic archived. No new replies allowed.