Possible Duplicate:
Repeated random number in a loop
感谢此前的评论意见,我更新了该守则。
首先,主要职能是:
int main ()
{
//DefineRelationstozero (); //All predecessors are set to -1
srand((unsigned)time(0));
.......
......
......
for (int k=0;k<iterationnumber;k++)
{
.....
RandomKey ();//i call randomkey for every iteration
}...
void RandomKey ()
{
for (int k=0;k<ActivityNumber;k++)
{
Act_num[k].Priority=(rand()%10000)*0.0001;//random number
}
for (int i=0;i<ActivityNumber;i++)
arr[i]=Act_num[i].Priority;
....
循环:对于每一代人来说,错误数字完全相同。