Non repeating random number array

前端 未结 6 1949
攒了一身酷
攒了一身酷 2020-12-21 20:49

I need to make a typical integer filled array with 10 random non repeating numbers from 0 to 20. Also, I need to be able to modify this so I can exclude some random numbers

6条回答
  •  被撕碎了的回忆
    2020-12-21 21:12

    First build a list of size 20 with values 0,...,19
    Then shuffle() it
    And last - take the sublist containing first 10 elements.

提交回复
热议问题