MathRand
MathRand
在0到32767之间返回随机整数。
int MathRand();返回值
整数值在0到32767之间。
注释
在第一次调用前,调用 MathSrand 建立初始状态伪随机数是有必要的。
注释
取代MathRand()可以使用 rand()。
示例:
//+------------------------------------------------------------------+
//| 脚本程序起始函数 |
//+------------------------------------------------------------------+
void OnStart()
{
//--- 设置新的初始状态,在每次启动时生成一系列伪随机整数
MathSrand(GetTickCount());
//--- 在循环中,在日志中显示10个生成的伪随机整数
for(int i=0; i<10; i++)
{
int rand_value=MathRand();
PrintFormat("Pseudorandom integer №%d: %u",i+1,rand_value);
}
}