對C++ Builder中random()函數(shù)說明的翻譯:
random
所在的頭文件
stdlib.h
原型
int random(int num);
random函數(shù)返回一個0~num-1之間的隨機數(shù). random(num)是在stdlib.h中的一個宏定義. num和函數(shù)返回值都是整型數(shù).
2描述編輯
random()函數(shù)將生成偽隨機數(shù)。
3語法編輯
在arduino中
random(max)
random(min, max)
min - 隨機數(shù)的最小值,隨機數(shù)將包含此值。 (此參數(shù)可選)
max - 隨機數(shù)的最大值,隨機數(shù)不包含此值。( 數(shù)據(jù)類型為long )
形式:random(long max)
random(long min, long max)
參數(shù):max為輸出隨機數(shù)范圍的最大值。
min為輸出隨機數(shù)范圍的最小值。
該函數(shù)以randomSeed()設(shè)定的種子輸出指定范圍的整數(shù)偽隨機數(shù),random(long max)相當于random(0,long max),輸出0~max范圍的整數(shù)隨機數(shù)。該函數(shù)的使用可以參考代碼清單2-25。