这段代码使用了rand()函数生成了随机数,并将随机数存储在数组a中。但是,这段代码没有明确说明想要生成多少个随机数,并将数组大小设为了100。所以,实际上只是生成了100个随机数,而不是想要的n个随机数。如果想要生成n个随机数,需要在代码中添加一个变量n,来指定要生成的随机数的个数,然后将数组大小设为n。

#includestdioh#include stdlibh#includetimeh#define M 100int main	int aM;		int in;	n=M;	 srand timeNULL ; for i = 0; i n; i++ 	ai=rand11; printf d dn iai ;	 	 为什么

原文地址: https://www.cveoy.top/t/topic/ijMl 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录