waiting...'s Blog

产生介于某一返回的随机数的函数

 

  1. // 返回一个介于lower与upper之间的随机数
  2.  
  3. #include <cstdlib>
  4.  
  5. int rand_int(int lower, int upper)
  6. {
  7.         return lower + rand() % (upper - lower + 1);
  8. }

 

 




Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee