insert random number

How can we insert two independent random number to two equations (x,y) contain two parts like this:
x = a* randomnumber1 + b* randomnumber2
y = c* randomnumber1 + d* randomnumber2
these two random number should be independent.

Is there a reason you haven't tried created two variables called randomnumber1 and randomnumber2, respectively, and assigning a random value to each with rand() or whatever you like?
you mean like this:

1
2
3
4
5
6
7
srand(time(NULL)); 

float   Random1 = (float(rand())/(RAND_MAX)) + 1
float   Random2 = (float(rand())/(RAND_MAX)) + 1

x = a* random1 + b* random2 
y = c* random1 + d* random2


or like:
1
2
3
std::srand(std::time(NULL)); // use current time as seed for random generator
int s1 = std::rand();
int s2 = std::rand();
Last edited on
Something like that, yes. Is that not what you want?
Topic archived. No new replies allowed.