#include <algorithm>
#include <numeric>
#include <list>
#include <cassert>
#include <vector>
#include <functional>
#include <iterator>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int ia[] = {29, 23, 20, 22, 17, 15, 26, 51, 19, 12, 35, 40};
sort(&ia[0], &ia[12]);
copy(&ia[0], &ia[12], std::ostream_iterator<int>(cout, " "));
cout<<endl;
bool found_it = binary_search(&ia[0], &ia[12], 18);
if (found_it == false)
cout<<"not found"<<endl;
vector<int> vec(ia, ia + 12);
sort(vec.begin(), vec.end(), greater<int>());
copy(vec.begin(), vec.end(), std::ostream_iterator<int>(cout, " "));
cout<<endl;
found_it = binary_search(vec.begin(), vec.end(), 26, greater<int>());
if (found_it == true)
cout<<"found"<<endl;
system("pause");
return 0;
}