min_element() max_element()
max_element()和min_element()
作用:去容器内的最大和最小值
头文件:#include <algorithm>
格式:
代码:
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int num[] = { 0,1,2,3,4,5 };
    cout << "最小值是 " << min_element(num, num+6) << endl;
    cout << "最大值是 " << max_element(num, num+6) << endl;
    system("pause");
    return 0;
}
 
                    
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号