1 #include<iostream> 2 #include<algorithm> 3 using namespace std; 4 bool cmp(int a,int b) 5 { 6 return a<b; 7 } 8 int main() 9 { 10 int num[]={2,3,1,6,4,5}; 11 cout<<"最小值是 "<<*min_element(num,num+6)<<endl; 12 cout<<"最大值是 "<<*max_element(num,num+6)<<endl; 13 cout<<"最小值是 "<<*min_element(num,num+6,cmp)<<endl; 14 cout<<"最大值是 "<<*max_element(num,num+6,cmp)<<endl; 15 return 0; 16 }