c语言写一个1-1000之间生成随机数的程序
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int randomNum;
srand(time(NULL)); // 设置随机数种子为当前时间
for (int i = 1; i <= 10; i++) // 生成10个随机数
{
randomNum = rand() % 1000 + 1; // 生成1-1000之间的随机数
printf("%d\n", randomNum);
}
return 0;
}
原文地址: http://www.cveoy.top/t/topic/qWd 著作权归作者所有。请勿转载和采集!