01: #include <iostream>
02: #include <vector>
03: 
04: using namespace std;
05: 
06: /**
07:    Returns the positions of all values within a range
08:    @param v a vector of floating-point numbers
09:    @param low the low end of the range
10:    @param high the high end of the range
11:    @return a vector of positions of values in the given range
12: */
13: vector<int> find_all_between(vector<double> v, 
14:    double low, double high)
15: {  
16:    vector<int> pos;
17:    for (int i = 0; i < v.size(); i++)
18:    {  
19:       if (low <= v[i] && v[i] <= high)
20:          pos.push_back(i);
21:    }
22:    return pos;
23: }
24: 
25: int main()
26: {  
27:    vector<double> salaries(5);
28:    salaries[0] = 35000.0;
29:    salaries[1] = 63000.0;
30:    salaries[2] = 48000.0;
31:    salaries[3] = 78000.0;
32:    salaries[4] = 51500.0;
33: 
34:    vector<int> matches
35:       = find_all_between(salaries, 45000.0, 65000.0);
36: 
37:    for (int j = 0; j < matches.size(); j++)
38:       cout << salaries[matches[j]] << "\n";
39:    return 0;
40: }