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; 

原文地址:https://www.cnblogs.com/jasonxu19900827/p/5520274.html