For the sake of simplicity, let's say the user enters n = 2, what I want to happen is for two (or n) random numbers to be multiplied together. It should work for any n, and where the random numbers are between 0 and 1.
I have been using this for random numbers between 0 and 1
(double)rand()/(double)RAND_MAX for this.
So to break it down further
n= 1
random_number = random_number
n = 2
random_number = random_number * random_number
n = 3
random_number = random_number * random_number * random_number
n = ...
random_number = random_number * random_number * ...
The problem is the random numbers have to be unique as well. For example, for the case of n = 2, it should be ...
random_number = (unique)random_number * (unique)random_number
To complicate the matter further, let's also say I have m (not static) divisions, and I create a vector of size m^n. I also need to create this vector of size m^n to be...
vector = [rand*rand, rand*rand, rand*rand, rand*rand]
for the case when n = 2 m = 2
How would I go about doing this in c++?
Aucun commentaire:
Enregistrer un commentaire