C++ Array Shuffle

后端 未结 10 1992
温柔的废话
温柔的废话 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:40

    Basic arrays can't be defined with variable passed as size, as mentioned above.

    And be careful there. Last element of

    typename array[SIZE];

    is array[SIZE-1], not array[SIZE]. It's probably where you getting a segfault.

    You really should at lest try to use STL containers. STL has shuffle algorithms too (:

提交回复
热议问题