c 语言 随机生成数函数

int theRandom = 0; 

theRandom = arc4random_uniform(3)//随机生成一个从0到2的数

或者

#include "stdio.h" 

#include "stdlib.h"

#include "time.h"

int main(){

srand((unsigned)time(NULL);//用时间做种子,使每次产生的随机数不一样

int randomNum = rand()%3; 

posted @ 2016-05-23 15:48  JasonXu_徐晓峰的博客  阅读(262)  评论(0编辑  收藏  举报