【发布时间】:2018-09-21 14:33:49
【问题描述】:
int array[5];
int Random;
for (int i = 0; i <5; i++)
{
cin>>array[i];
}
for (int j = 0; j < 5; j++)
{
Random = array[rand() % array[j]];
}
cout << Random << endl;
这让我不断返回 1,但我每次都想要不同的数字
【问题讨论】:
-
请编辑您的问题以包含minimal reproducible example
-
array[rand() % array[j]]看起来是一个非常容易超出数组范围的地方。 -
@scohe001 Randal Number Generator 怎么样