answersLogoWhite

0

That depends on the programming language and the exact implementation of max. Normally, a max function returns the largest of two variables of the same type but can also be applied to a sequence container with 2 or more elements. Both versions may also include a user-defined predicate to perform the comparison(s).

In the C++ standard library, it is implemented as a generic algorithm (a function template) with 4 overloads. These functions become accessible when you include the <algorithm> header from the standard library. They each have the following definitions:

// TEMPLATE FUNCTION max

template<class _Ty> inline

_Post_equal_to_(_Left < _Right ? _Right : _Left)

const _Ty& (max)(const _Ty& _Left, const _Ty& _Right)

{ // return larger of _Left and _Right

return (_DEBUG_LT(_Left, _Right) ? _Right : _Left);

}

template<class _Ty> inline

_Ty (max)(_XSTD initializer_list<_Ty> _Ilist)

{ // return leftmost/largest

const _Ty *_Res = _STD max_element(_Ilist.begin(), _Ilist.end());

return (*_Res);

}

// TEMPLATE FUNCTION max WITH PRED

template<class _Ty,

class _Pr> inline

const _Ty& (max)(const _Ty& _Left, const _Ty& _Right, _Pr _Pred)

{ // return larger of _Left and _Right using _Pred

return (_DEBUG_LT_PRED(_Pred, _Left, _Right) ? _Right : _Left);

}

template<class _Ty,

class _Pr> inline

_Ty (max)(_XSTD initializer_list<_Ty> _Ilist, _Pr _Pred)

{ // return leftmost/largest

const _Ty *_Res = _STD max_element(_Ilist.begin(), _Ilist.end(), _Pred);

return (*_Res);

}

User Avatar

Wiki User

10y ago

What else can I help you with?

Continue Learning about Engineering

Can you write a source code to find the sum and the largest number of a given array?

In Java, assuming you already created an array of int's, called myArray:int max = myArray[0];int sum = 0;for (int i = 0; i < myArray.length; i++){sum += myArray[i];if (myArray[i] > max)sum = myArray[i]}


Write a method that takes 3 values as input parameters and returns the largest of three values?

public int max(int x, int y, int z){ return Math.max(x,Math.max(y,z)); } The method Math.max() only accepts 2 arguments, so you need to perform this method twice if you want to compare 3 numbers, as per the code above.


What is the code for the side ways heart code?

Hello woozens! i am delighted to see you! the answer to the heart code on woozworld is max&amp;jenny2gether4ever. thanks..... i am megan020 on woozworld so check out my profile! until next time this is Megan020


Find largest value algorithm in c?

** pseudo code ** if array length == 1, return first element else if array length &gt; 1 max = first element for second item to last item if item &gt; max max = item return max else // array length is 0 error


Which are the matoshinno commands?

Just put in the email the valid code and you will receive the next commands by email for each code and for each email. You need to have an unused code. It is recommended to double your code first. this will take a while (max 7 days), but you will have now two valid codes. If you have enough BTC to double you can email then the second code from another email and again to double it or to double BTC... or you can give the code to your friends...or to sell it!

Related Questions

How did Max Planck use the scientific method?

did max planck follow the scientific method


Can you write a source code to find the sum and the largest number of a given array?

In Java, assuming you already created an array of int's, called myArray:int max = myArray[0];int sum = 0;for (int i = 0; i < myArray.length; i++){sum += myArray[i];if (myArray[i] > max)sum = myArray[i]}


Which method of determining exercise intensity correlates directly to 60 percent - 80 percent of your VO2 max?

The method of exercise intensity based on a percentage of your VO2 max that directly correlates to 60 percent - 80 percent of your max VO2 is called the &quot;percentage of VO2 max method.&quot; This method uses a moderate to vigorous intensity level that falls within the 60-80% range of your maximum oxygen consumption. It is commonly used in setting target heart rate zones for aerobic exercise.


All items ar max code for kingdom hearts 2?

There is no code for max items.


What is the max power for a Haines Hunter V133R?

THE MAX POWER IS 300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp source


What is the woozworld ballroom code?

The code? Easy max&amp;jenny2gether4ever


What is the secret code in the ballroom?

well this code is in wooozworld so the code is max&amp;jenny2gether4ever


What is max georges brother called?

Max's Brother is called Jack


What is Ella and Max's friend code on Disney superbia?

i only know max its boy01


Is there a ar code for max revive seeds?

no


What is the Action Replay Max Code for getting the Mystic Ticket?

the code is:1134hsbho63ooiklo


Is there a action replay code for max cash in Pokemon platinum?

Max Cash code: 94000130 FCFF0000 B2101D40 0000000000000090 000F423F D2000000 00000000