min_element()和max_element
头文件:#include
作用:返回容器中最小值和最大值。...max_element(first,end,cmp);其中cmp为可选择参数!...闲言少叙,上代码,一看就懂:
1 #include
2 #include
3 using namespace std;
4 bool cmp...return a<b;
7 }
8 int main()
9 {
10 int num[]={2,3,1,6,4,5};
11 cout<<"最小值是 "<<*min_element...<*min_element(num,num+6,cmp)<<endl;
14 cout<<"最大值是 "<<*max_element(num,num+6,cmp)<<endl;
15