Special simple random number generator

后端 未结 7 2149
一整个雨季
一整个雨季 2020-12-01 08:47

How to create a function, which on every call generates a random integer number? This number must be most random as possible (according to uniform distribution). It is only

7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-01 08:49

    Here's a function with uniform distribution over the entire range of int:

    int rand()
    {
      static int random = 0;
      return random++;
    }
    

提交回复
热议问题