0
Why the results here are the same? How can I make it generate two diff numbers?
8 Respuestas
+ 5
Move the srand(time(0)) to the main function, like this:
https://code.sololearn.com/czGNvmKkOTs4/?ref=app
+ 4
As to why it is the same, well... we just don't do it that way. 😉
+ 4
Well, technically you can, but you may get unexpected and unwanted results (like the equal "random" results just now.) 😉
+ 1
Ok, now I know. I thought srand(time(0)) can be put outside main. Thank you 😀
0
May I know how can I use it on my code?
0
Sure haha. btw thanks
- 1
Use <random> instead of rand(). It was introduced because rand has some issues.
- 1
It's a bit complicated, please look in the internet. They explain it better than me.