This question already has an answer here:
- How to generate a random number in C++? 6 answers
Is there an alternative to rand()?Since rand()(at least for me)is freaking broken.So if you know an alternative to rand() in c++ please tell me.Since every time i run this simple code:
Code:
#include <iostream>
#include <cstdlib>
using namespace std;
void Gla()
{
int L;
L = rand();
while(1)
{
cout<<L<<endl;
}
}
int main()
{
Gla();
return 0;
}
It continously outputs 41, i don't know why it just does.
Aucun commentaire:
Enregistrer un commentaire