Difference between revisions of "CPP/STL/VectorMinAndMax"

From ProgrammingExamples
< CPP
Jump to: navigation, search
(Created page with '==VectorMinAndMax.cpp== <source lang="cpp"> #include <iostream> #include <vector> #include <algorithm> int main() { std::vector<int> v; v.push_back(1); v.push_back(2); v…')
 
(No difference)

Latest revision as of 08:55, 26 February 2011

VectorMinAndMax.cpp

#include <iostream>
#include <vector>
#include <algorithm>
 
int main()
{
  std::vector<int> v;
  v.push_back(1);
  v.push_back(2);
  v.push_back(3);
 
  std::cout << *(std::min_element(v.begin(), v.end())) << std::endl;
  std::cout << *(std::max_element(v.begin(), v.end())) << std::endl;
 
  return 0;
}

CMakeLists.txt

cmake_minimum_required(VERSION 2.6)
 
PROJECT(VectorMinAndMax)
ADD_EXECUTABLE(VectorMinAndMax VectorMinAndMax.cpp )