Give me a code in C++ showing the algorithm to generate pseudo random numbers. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Give me a code in C++ showing the algorithm to generate pseudo random numbers.

Algorithm to Pseudo Random Numbers in C++.

3rd Jan 2019, 1:17 PM
Koustav Dhar
Koustav Dhar - avatar
3 Answers
+ 2
Heres a simple way -int i=rand()%10; It will generate some random value btn 0-10; C++ provides a better alternative to this tho.. Its available in the header <random>, Refer to "C++ standard library refrence" to learn more..
3rd Jan 2019, 2:46 PM
Mensch
Mensch - avatar
+ 2
Well Simon I know that by using rand or random function...we can do that Actually my question was not clear... I actually asked about the algorithm... Can anyone throw any light on the algorithm of pseudo random number generator
3rd Jan 2019, 3:46 PM
Koustav Dhar
Koustav Dhar - avatar
+ 1
int Seed; int GetRandom(int Max){ return ( Seed *= 5435362342352535 ) % Max; } jprd aż się nie chce na takie pytanie odpisywać po ang. ponieważ szybciej mi będzie w pl. nie ma algorytmu na randomy, pobierane jest ono z czasu komputera więc jak chcesz kurw* zrobić algorytm? pobierasz CZAS aby dostać radomowego numera...
4th Jan 2019, 2:01 AM
Tobi PL
Tobi PL - avatar