help understanding code (random number)# Programming - 葵花宝典
c*t
1 楼
Hi, this is copy&paste from a piece of code I am reading, but
can't understand:
int nc[5], extObt = 0;
set freeNumbers;
......
set::iterator si;
for (si = freeNumbers.begin(); si != freeNumbers.end() && extObt < 5;
++si)
{
if ((*si) % 200 == (rand() % 82))
{
nc[extObt] = (*si);
extObt++;
}
}
The funciton of the code is to randomly pick up 5 numbers from the set
of freeNumbers, but I can't understand how it i
can't understand:
int nc[5], extObt = 0;
set
......
set
for (si = freeNumbers.begin(); si != freeNumbers.end() && extObt < 5;
++si)
{
if ((*si) % 200 == (rand() % 82))
{
nc[extObt] = (*si);
extObt++;
}
}
The funciton of the code is to randomly pick up 5 numbers from the set
of freeNumbers, but I can't understand how it i