I am trying to fill a vector with 5000 random numbers. Each number is an integer. But i am wondering why rand() only gives unsigned integers and also it never gives the max values that an integer can hold. Is there a reason for that?
unsigned seed = time(0);
srand(seed);
vector<int> vect(5000);
for (int i = 0; i < vect.size(); i++)
{
vect[i] = rand();
}
Aucun commentaire:
Enregistrer un commentaire