Generate random number in a range [0, n) in C?

后端 未结 4 968
小蘑菇
小蘑菇 2021-01-26 01:13

Looking to make a really simple random number generator method in C. The numbers should be between 0 and 24 and can be for example 14.5f.

Any help would be great, thanks

4条回答
  •  有刺的猬
    2021-01-26 01:48

    Have a look at linear congruential generators, they are quite simple to implement even with my inferior math knowledge.

    Looks like I misunderstood the original question, I thought you wanted to roll your own generator (for homework, fun etc.)

提交回复
热议问题