Non-repeating random number generator

后端 未结 7 1836
清酒与你
清酒与你 2020-12-21 00:57

I\'d like to make a number generator that does not repeat the number it has given out already (C++).

All I know is:

int randomgenerator(){
  int ran         


        
7条回答
  •  情话喂你
    2020-12-21 01:26

    Create a vector of 10 elements (numbers 1-10), then shuffle it, with std::random_shuffle. Then just iterate through it.

提交回复
热议问题