
- Kód: Vybrat vše
#include <iostream>
#include <cstdlib>
using namespace std;
int main() {
cout << rand()%20 << endl;
cout << rand()%20 << endl;
return 0;
}
Moderátor: Moderátoři Živě.cz
#include <iostream>
#include <cstdlib>
using namespace std;
int main() {
cout << rand()%20 << endl;
cout << rand()%20 << endl;
return 0;
}
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main() {
srand(clock());
cout << rand()%20 << endl;
cout << rand()%20 << endl;
return 0;
}
boost::mt19937 rng; // typ pseudo generatoru
boost::uniform_int<> sestka(1,6) // distribuce hodnot 1 az 6
boost::variate_generator<boost::mt19937&, boost::uniform_int<> >kostka(rng, sestka); // spojeni generatoru a distribuce => kostka6
int x = kostka(); // jeden hod kostkou
/dev/random píše: The /dev/random and /dev/urandom character devices provide cryptographically secure random output generated from interrupt timings or input written to the devices.
The /dev/random device is intended to provide high quality, cryptographically secure random output and will only return output for which sufficient (an equal or greater amount) random input is available to generate the output. If insufficient random input is available, reads from the /dev/random device will block until the request can be fulfilled unless the O_NONBLOCK flag was specified when the device was opened, in which case as much high quality output as could be generated is returned with the error code EAGAIN.
The /dev/urandom device provides a reliable source of random output, however the output will not be generated from an equal amount of random input if insufficient input is available. Reads from the /dev/urandom device always return the quantity of output requested without blocking. If insufficient random input is available, alternate input will be processed by the random number generator to provide cryptographically secure output, the strength of which will reflect the strength of the algorithms used by the random number generator. Output generated without random input is theoretically less secure than output generated from random input, so /dev/random should be used for applications for which a high level of confidence in the security of the output is required.
Uživatelé procházející toto fórum: Žádní registrovaní uživatelé a 0 návštevníků