Mega Code Archive

 
Categories / C++ / Vector
 

Find the min value in the vector

#include <algorithm> #include <iostream> #include <vector> using namespace std; int main(int argc, char** argv) {   int elems[] = {5, 6, 9, 8, 8, 3};   vector<int> myVector(elems, elems + 6);    vector<int>::const_iterator it, it2;     // Find the min and max elements in the vector   it = min_element(myVector.begin(), myVector.end());   cout << "The min is " << *it << endl;   return (0); }