33,321
社区成员




#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main(void)
{
int i,n;
i=0;
time_t t1; /* 用于存放时间 */
time(&t1); /* 取得当前系统时间 */
srand(t1); /* 设置随机数的种子,使得每次运行试产生不同的随机数 */
printf("请输入产生随机数的个数:\n");
scanf("%d",&n);
while(i<n)
{
printf("第%d个随机数:%d\n",i+1,rand()%90+10);
i++;
}
return 0;
}
这样更合适。#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void main()
{
int a;
srand(time(NULL));
printf("请输入产生随机数的范围:");
scanf("%d",&n); //n=99
a=(rand()%(n-10)+10;
printf("The Random Number is %d .\n", a);
}