怎样用C语言编写程序产生20个100以内的随机数,然后输出数组各元素?

如题所述

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{ int i,number[20];
srand((unsigned) time(NULL)); //用时间做种,每次产生随机数不一样
for (i=0; i<20; i++)
{
number[i] = rand() % 100; //产生0-100的随机数
printf("%d ", number[i]);
}
return 0;
}
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答