#include<iostream>
#include<cstdlib>
#include<vector>
#include <algorithm>

using namespace std;

int main(int argc, char ** argv)
{
    vector<double> v1(10);
    vector<double>::iterator i;
    vector<double>::const_iterator position;
    double key = 5.7;

    double n=10.0;
    for(i=v1.begin(); i!=v1.end(); i++)
    {
        *i = n-=0.5;
        cout<<*i<<" ";
    }
    cout<<endl;

    position = find( v1.begin(), v1.end(), key );

    while(position == v1.end())
    {
        key-=0.1;
        cout<<"key: "<<key<<endl;
        position = find(v1.begin(), v1.end(), key);
        cout<<"index: "<<position - v1.begin()<<endl;
        if(key<5.0) break;
    }
    int index = position - v1.begin();
    cout<<"index: "<<index<<endl;
    return 0;
}
