samedi 31 janvier 2015

Random() efficiency in C++

I am writing function where I need to find the random number between 1 - 10. One of the easiest way is to use random() libc call. I am going to use this function a lot. But I don't know how efficient it will be. If any one has idea about efficiency of random() that will be a help ?


Also I notice that random() give the same pattern in 2 runs.



int main()
{
for(int i=0;i<10;i++)
{
cout << random() % 10 << endl;
}
}


Output 1st time :- 3 6 7 5 3 5 6 2 9 1


Second time also I got same output.


Then how come it's random ?





Aucun commentaire:

Enregistrer un commentaire