Range of the function on the generated c ++ to rand ()

1, rand ()% 100 // returns a random number in the interval 0-99
2,10 + rand ()% 90 // obtained [10,99] a random number in interval
3, a + rand ()% b // get [a, a + b-1 ] a random number in the interval
4, rand ()% 100 / 100.0 // get a random number in the range of 0.00-0.99
5, rand ()% 90 / 10.0 + 1 // get the real number has a decimal in the range of 1.0-9.9

Published 10 original articles · won praise 0 · Views 30

Guess you like

Origin blog.csdn.net/qq_44933833/article/details/104884994