#include <algorithm> // std::min_element, std::max_element
bool myfn(int a,int b){
return a < b;
}
int myints[] = {3,7,2,5,6,4,9};
// using default comparison:
cout << "The smallest " << *min_element(myints,myints+7) << endl;
cout << "The largest " << *max_element(myints,myints+7) << endl;
// using function myfn as comp:
cout << "The smallest " << *min_element(myints,myints+7,myfn) << endl;
cout << "The largest " << *max_element(myints,myints+7,myfn) << endl;