Generating random non repeating number array in C++

前端 未结 1 1894
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-22 18:02

I need to generate random non repeating number array in C++, in this part of code I generate random numbers using, srand function, but some of the numbers are repeating. The mai

相关标签:
1条回答
  • 2021-01-22 18:41

    One strategy is to populate an array with numbers from 1 to 75, and then use std::random_shuffle() on it. You can then read the numbers from the array until you hit the golden number.

    0 讨论(0)
提交回复
热议问题