要注意该类函数作用范围是两参数左闭右开区间
#include <algorithm>
用min和max函数
1)对于普通数组
int arr[len]
int min = min(arr,arr+len);
2)对于动态数组vector
vector<int> arr;
int *min = min(arr.begin(), arr.end());
用min_element和max_element函数
1)对于普通数组
int a[5] = { 2, 3, 5, 4, 5 };
int max = max_element(a, a + 5);
2) 对于动态数组vector
int main()
{
int a[] = { 2, 3, 5, 4, 5 };
vector<int>b(a,a+5);
vector<int>::iterator p = max_element(b.begin(), b.end());
vector<int>::iterator q = min_element(b.begin(), b.end());
cout << *p << endl;
cout << *q << endl;
system("pause");
return 0;
}