Max In a C++ Array

后端 未结 3 1498
傲寒
傲寒 2021-02-05 20:31

I am trying to find the \'biggest\' element in a user made array ,by using the max function from the algorithm library/header.

I have done some research on the cplusplus

3条回答
  •  离开以前
    2021-02-05 21:01

    You can also use std::array by #include

    #include 
    #include 
    #include 
    using namespace std;
    int main()
    {
    array arr;
    int n = 10;
    for (int i = 0; i < n; i++) {
    arr[i] = i;
    }
    arr[5] = 5000;
    
    
    cout<<"Max: "<< *max_element(arr.begin(),arr.end())<

    More info on std::array

提交回复
热议问题