1110.求数组或vector元素最大最小值

#include <iostream>                                                                                                                                                                                              
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
    int arr[6] = {8,1,5,2,90,11};

    vector<int> vec;

    vec.push_back(80);
    vec.push_back(81);
    vec.push_back(91);
    vec.push_back(33);
    vec.push_back(21);
    
    cout << "minvec: " << *min_element(vec.begin(),vec.end()) << endl;
    cout << "maxvec: " << *max_element(vec.begin(),vec.end()) << endl;

    cout << "min: " << *min_element(begin(arr),end(arr)) << endl;
    cout << "min: " << *max_element(begin(arr),end(arr)) << endl;

    return 0;
}

输出如下:

posted @ 2023-03-14 19:37  test369  阅读(14)  评论(0编辑  收藏  举报