+ 1

Random in c++

Is there a way to include random number generators in c++?

27th Apr 2019, 1:30 AM
Pikachu
Pikachu - avatar
1 ответ
+ 6
Judging by your use case, srand() and rand() would suffice, where srand() seeds the RNG and rand() generates a random number. https://www.sololearn.com/Discuss/151849/?ref=app #include <iostream> #include <cstdlib> // rand, srand #include <ctime> int main() { srand(time(0)); std::cout << rand(); } Ofc, if you want to venture even further, look into <random>. https://en.cppreference.com/w/cpp/header/random
27th Apr 2019, 1:42 AM
Hatsy Rei
Hatsy Rei - avatar