没事啥子说的,直接上代码:
//获得0~1之间的随机数
int R1 = CCRANDOM_0_1();
//获得0~100之间的随机数
int R100 = CCRANDOM_0_1()*100;
CCRANDOM_0_1()源代码:
/** @def CCRANDOM_0_1
returns a random float between 0 and 1
*/
#define CCRANDOM_0_1() ((float)rand()/RAND_MAX)
没事啥子说的,直接上代码:
//获得0~1之间的随机数
int R1 = CCRANDOM_0_1();
//获得0~100之间的随机数
int R100 = CCRANDOM_0_1()*100;
CCRANDOM_0_1()源代码:
/** @def CCRANDOM_0_1
returns a random float between 0 and 1
*/
#define CCRANDOM_0_1() ((float)rand()/RAND_MAX)