
srand((unsigned)time(NULL));在c语言中有什么具体的意思吗?
展开全部
如何运用time函数和srand函数生成随机数
#include <stdio.h>
#include <stdlib.h>//srand()、rand()
#include <time.h>//time();
#include <conio.h>
#define N 50
int main()
{
int n;
srand((unsigned)time(NULL));//设置随机数种子
while (1)
{
n = (rand() % 10) + 1 ;//产生1~10的随机数
//rand()产生的是一个很大的数,对其求余就可以达到限定范围的目的
printf("%d ", n);
getch();
}
return 0;
}
#include <stdio.h>
#include <stdlib.h>//srand()、rand()
#include <time.h>//time();
#include <conio.h>
#define N 50
int main()
{
int n;
srand((unsigned)time(NULL));//设置随机数种子
while (1)
{
n = (rand() % 10) + 1 ;//产生1~10的随机数
//rand()产生的是一个很大的数,对其求余就可以达到限定范围的目的
printf("%d ", n);
getch();
}
return 0;
}

2022-08-05 广告
苏州蓝晓生物科技有限公司。标准化核心产品:公司拥有完整的琼脂糖介质、葡聚糖介质、聚甲基丙烯酸酯介质生产线,年产分离介质50000L,产品质量稳定并达到国际领先水平。核心优势:公司核心技术人员拥有近二十年不同基质的基球开发和官能化的丰富技术经...
点击进入详情页
本回答由苏州蓝晓生物科技有限公司_提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询