C++ Array Shuffle

后端 未结 10 2027
温柔的废话
温柔的废话 2021-01-07 14:06

I\'m fairly new to C++ and don\'t quite understand function parameters with pointers and references. I have an array of Cards that I want to shuffle using the Fisher-Yates

10条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-07 14:49

    You could also use

    std::random_shuffle(deck, deck + deckSize)

    which does Fisher-Yates for you.

    However, there probably aren't enough bits in the standard random libraries to genuinely choose from all possible random permutations of cards.

提交回复
热议问题