Untitled

 avatar
user_9831585
plain_text
2 years ago
367 B
7
Indexable
int findmaxvalue(int* arr, int n)
{
    if (n == 0)
    {
        std::cout<<"Error -> There are no values in the array"<<std::endl;
        return 0;
    }
    if (n == 1)
    {
        return arr[0];
    }
    int maxValue = findmaxvalue(arr + 1, n - 1);
    if (arr[0] > maxValue)
    {
        return arr[0];
    }
    else
    {
        return maxValue;
    }
}
Editor is loading...