I need to create randoms edges in a weighted graph with int non-zero weight. I can't find any solution to create the random generator in c++ able to me return an int with some non-zero value in a range.
my following function can be illustrate better my problem:
/* Non-zero random integer numbers generator in closed interval */
#include <cstdlib>
#include <ctime>
int randomize(int upper_limit, int lower_limit){
srand(time(NULL));
int x = 0;
do
{
x = rand() ...what I need to do?
}
while(resp == 0);
return x;
}
Aucun commentaire:
Enregistrer un commentaire