ASTeterin / OOP

0 stars 0 forks source link

Замечания по FindMax #11

Closed alexey-malov closed 5 years ago

alexey-malov commented 5 years ago
template <typename T>
bool FindMax(std::vector<T> const& arr, T& maxValue)
{
    if (arr.empty())
    {
        return false;
    }
    auto maxElement = arr[0];

    for (auto currentElement : arr)
    {
        if (maxElement < currentElement)
        {
            maxElement = currentElement;
        }
    }

    maxValue = maxElement;
    return true;
}
alexey-malov commented 5 years ago