mercredi 7 septembre 2016

How to generate big random integer using gmplib with start random point, like srand from C++?

I need generate big random integer. I use this code:

mpz_t a;
mpz_init(a);
int mod=5;
gmp_randstate_t rnd;
gmp_randinit_mt(rnd);    
mpz_urandomb (a, rnd, mod);
gmp_randclear(rnd);
char* tmp = mpz_get_str(NULL,10,a);
cout << tmp;
delete []tmp;

But every time you start the program generates the same number 20. How to set start point for parameter rnd, like srand() from C++ STL?




Aucun commentaire:

Enregistrer un commentaire