// find1.cpp: Finding a given value in a list
#include <iostream>
#include <list>
#include <algorithm>
using namespace std;

int main() {
 int x,y = -1;
 list<int> v;
 v.push_back(2); v.push_back(5); v.push_back(8);
 cout << "Enter an integer to be found in (2, 5, 8):\n";
 cin >> x;
 list<int>::iterator i = find(v.begin(), v.end(), x);
 if (i == v.end()) 
  cout << "Not found.";
 else {
  cout << "Found: ";
  if (i == v.begin())
   cout << "as the first element.";
  else cout << "after " << *--i;
 } 
 return 0;
}
