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;
}
posted @ 2022-07-31 22:02  李新乾  阅读(25)  评论(0编辑  收藏  举报