如何用C产生0-99随机数?

#include
#include
#include
#define randomize() srand((unsigned)time(NULL)) //定义一个宏

 

int main(void)
{
int i;
printf("Ten random numbers from 0 to 99/n/n");


randomize();


for(i=0; i<100; i++)
{
printf("%d/n", rand() % 100);
sleep(1);
}

 

return 0;
}

 

<运行>

root@farsight:/mnt/hgfs/E/yinhui/12.3/msg# gcc tttt.c -o tttt
root@farsight:/mnt/hgfs/E/yinhui/12.3/msg# ./tttt
Ten random numbers from 0 to 99

87
80
68
39
39
53
14
96
46

你可能感兴趣的:(numbers,random,c,include,gcc,null)