Max In a C++ Array

后端 未结 3 1604
傲寒
傲寒 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:06

    max_element is the function you need. It returns an iterator to the max element in given range. You can use it like this:

    cout << " max element is: " << *max_element(array , array + n) << endl;
    

    Here you can find more information about this function: http://en.cppreference.com/w/cpp/algorithm/max_element

提交回复
热议问题