c/c++中产生随机数

相关函数:rand()函数, srand()函数

rand():返回一随机数值, 范围在0至RAND_MAX 间

void srand (unsigned int seed):设置rand()产生随机数时的随机数种子。

示例:

#include<stdio.h>
#include<stdlib.h>
#include<time.h>

void main()
{
     srand((int)time(0));                          
     for(int x=0;x<10;x++)
           printf("%d/n",rand()%100);
}
原文地址:https://www.cnblogs.com/lsr-flying/p/4728394.html