Code Flow (loops and arrays)


Hi: Thank you for taking time to help me with my problem. I am having problems understanding where this code is wrong as I believe that I am not receiving the correct outputs. I have truncated the code to the most pertinent.

The algorithm asks that every value in array1 be divided by array2
and if that value is less than the ratio * array3 (percentage filter) then output.

I have no problem with the code with the exception of
abs(ratio*array3[m]

Assuming that the ratio = 1 then all values get outputted, I want the array1 (first value) to have the first value in array3 assigned to it, the second value in array1 to have the second value in array3 to be assigned.

So:
array1 (1.0) with array3 (0.05)
array1 (2.0) with array3 (0.06)
etc.

or
array1 (1.0) with array3 (0.05)
array1 (3.0) with array3 (0.07)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

Code:
array1[5] = {1.0, 2.0, 3.0, 4.0, 5.0};
array2[5] = {1.0, 2.0, 3.0, 4.0, 5.0};
array3[5] = {0.05, 0.06, 0.07, 0.08, 0.09};

ratio = abc/def;

 for(int m=0; m<5; m++)
              {
               for(int n=0; n<5; n++)
                 {
                  if(abs(ratio-array1[m]/array2[n])<abs(ratio*array3[m]))
{
>>then print out values paired matches of array1[] and array2[]
}

Thank you again for pointing out any problem you see.
Is this actual C++ code?
What are the types of the arrays and 'ratio' ?

Pseudo code - my mistake. Problem is solved, thank you for responding.
Topic archived. No new replies allowed.