#include <algorithm>
#include <vector>
#include <list>
#include <iostream>
using namespace std;
int main ()
{
vector <int> v;
for (int nNum = -9; nNum < 10; ++ nNum)
v.push_back (nNum);
v.push_back (9);
v.push_back (9);
list <int> l;
for (int nNum = -4; nNum < 5; ++ nNum)
l.push_back (nNum);
// search the vector for the occurrence of pattern {9, 9, 9}
vector <int>::iterator vl;
vl = search_n ( v.begin () // Start range
, v.end () // End range
, 3 // Count of item to be searched for
, 9 ); // Item to search for
if (vl != v.end ()){
cout << "The sequence {9, 9, 9} found a match in the vector at ";
cout << "offset-position: ";
cout << distance (v.begin (), vl);
cout << endl;
}
return 0;
}