Thanks in advance for everyone's help.
I'm trying to write a program in c++ that includes a function that calculates all possible combinations of f1, f2, f3; where 15 = f_total = ((f1) / (f1+f2+F3)). Whenever true, the program will output the values of f(n) to stdout. Where the f(n)'s are 3 randomly generated fractional doubles, that are produced by a locally defined function `double functRand_f(f_min, f_max).
So with the backdrop out of the way, I'm hoping someone can just assist me with the actual syntax of the equation itself. How do I structure the equation syntax within the context of my functions:
.....
double funcRand_f(double fMin, double fMax)
{
double fRange = (fMax - fMin);
double div = RAND_MAX /fRange;
return (fMax - fMin) * ((double)rand() / (double)RAND_MAX) +fMin;
}
bool funcTotal_f(double x, double y, double z, double sum)
{
return (((x) / (x+y+z)) == f_sum);
return (f_total = sum);
}
....
I've tried looping to see when a match takes place. Moved around the decimal point, but after several several hours of trying to get it to work properly, I just can't get it to work.
I have the f1, f2, f3 all being assigned random numbers in a for loop before being passed to the funcTotal_f, and checked to make sure the values are peristant in and out of the methods before being overloaded with a new value.
Any guidance or a point to a resource that could help me figure it out is much appreciated. Thanks.