Creating random numbers with no duplicates

后端 未结 18 2069
忘了有多久
忘了有多久 2020-11-21 12:00

In this case, the MAX is only 5, so I could check the duplicates one by one, but how could I do this in a simpler way? For example, what if the MAX has a value of 20? Thanks

18条回答
  •  半阙折子戏
    2020-11-21 12:16

    I created a snippet that generates no duplicate random integer. the advantage of this snippet is that you can assign the list of an array to it and generate the random item, too.

    No duplication random generator class

提交回复
热议问题