<分区>
我希望这个程序生成 4 个不同系列的 4 个随机数。该程序当前为每个系列输出相同的数字。知道发生了什么事吗?我认为它与种子有关,但我不知 Prop 体是什么。
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
int lotArr[6];
int j = 0;
int k = 0;
int m = 0;
int n = 0;
int i = 0;
bool crit = false;
//interates through 4 sequences
for(int i = 0; i < 4; i++ )
{
srand(time(NULL));
//generates each number in current sequence
for(m = 0; m < 4; m++)
{
lotArr[m] = rand() % 30 + 1;
}
//output
for(n = 0; n < 4; n++)
{
cout << lotArr[n] << " ";
}
cout << endl;
}
return 0;
}