C++ 随机整数

[a, b) 之内的随机整数

(rand() % (b-a)) + a

[a, b] 之间的随机整数

(rand() % (b-a+1)) + a
原文地址:https://www.cnblogs.com/consolexinhun/p/15496798.html