#include <array>

#include <numeric>

#include <algorithm>

#include <random>


template< typename CARD, std::size_t SIZE >

void shuffle( std::array< CARD, SIZE >& deck )

{

    for( int count = deck.size(); count; --count )

        std::swap( deck[ rand() % count ], deck[ count - 1 ] );

}


template< typename CARD, std::size_t SIZE >

void shuffle2( std::array< CARD, SIZE >& deck )

{

    std::mt19937 mt; 

    for( int count = deck.size(); count; --count )

    {

        std::uniform_int_distribution<> random( 0, count - 1 ) ;

        std::swap( deck[ random( mt ) ], deck[ count - 1 ] );

    }

}


void test1()

{

    std::array< int, 54 > cards;

    std::iota( cards.begin(), cards.end(), 0 );

    shuffle( cards );

}


void test2()

{

    std::array< int, 54 > cards;

    std::iota( cards.begin(), cards.end(), 0 );

    std::shuffle( cards.begin(), cards.end(), std::mt19937 { std::random_device {}( ) } );

}


void test3()

{

    std::array< int, 54 > cards;

    std::iota( cards.begin(), cards.end(), 0 );

    shuffle2( cards );

}


range 를 변경해야하니 메르센 트위스터도 안빠르넹. 췌.