11智能在线
新记
怎样用C语言编写程序产生20个100以内的随机数,然后输出数组各元素?
如题所述
举报该文章
相关建议 推荐于2019-08-04
#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;
}
温馨提示:内容为网友见解,仅供参考
当前网址:
https://11.t2y.org/zz/msp4p27f42vfq2224p.html
其他看法
无其他回答
相似回答
大家正在搜
相关问题
用C语言编写程序产生20个100以内的随机数,然后输出数组各...
请问用C语言编写程序产生20个100以内的随机数,然后输出数...
用C语言编写程序产生20个100以内的随机数,然后输出数组各...
随机产生20个100以内的数,输出;按从小到大的顺序排序,输...
设计一个程序,使用随机数产生100个且元素的值在100以内的...
C语言程序:把20个随机数存入一个数组,然后输出该数组中的最...
麻烦请问“1.设计一个程序,使用随机数产生100个且元素的值...
c语言 由系统随机产生20个0-100之间的随机数,然后从键...