Random array generation with no duplicates

前端 未结 9 958
無奈伤痛
無奈伤痛 2020-11-28 12:48

I am trying to create something that generates a random array with no duplicate values. I\'ve already looked at other answers but none seem to help me understand. I cannot t

9条回答
  •  粉色の甜心
    2020-11-28 12:49

    After you generate each random number, loop through the previous values and compare. If there's a match, re-generate a new value and try again.

提交回复
热议问题