This question already has an answer here:
I want to generate random Number every time I call the
double Rand(){
srand ( time(NULL) );
double number=(double)rand()/((double)RAND_MAX+
return number;
}
cout<<Rand()<<endl;
cout<<Rand()<<endl;
cout<<Rand()<<endl;
the result is same for all of them. However I want them to be different. Could you please Help me??
Aucun commentaire:
Enregistrer un commentaire