1.randomSeed(Seed)
randomSeed(Seed)函数用来设置随机数种子,随机数种子的设置对产生的随机序列有影响。函数无返回值,原型如下:
void randomseed(unsigned int seed)
{
if (seed 1=0)
{
srandom(seed);
}
}
2.random(howsmall,howbig)
应用random函数可生成一个随机数,两个参数howsmall和howbig决定了随机数的范围,函数的参数及返回值均为long型,原型如下:
long random(long howsmall,long howbig)
{
if(howmall>=howbig)
{
return howsmall;
}
long diff=howbig-howsmall;
return random(diff)+howsmall;
}