C++ STL 求向量中的最大值和最小值max_element min_element1
2
3
4
5
6
7
8
9
10#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int n[]={1,4,22,3,8,5};
int len=sizeof(n)/sizeof(int);
cout<<*max_element(n,n+len)<<endl;
cout<<*min_element(n,n+len)<<endl;
return 0;
1 | // min_element/max_element example |