Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 13 / task8.cpp
blob: a22d3b766504a928f2698b5ed7c060d557fb0fef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
using namespace std;

int max(int a, int b)
{
	return a > b ? a : b;
}

int max(const int* arr, int len)
{
	if (len == 1)
		return arr[0];
	return max(arr[0], max(arr + 1, len - 1));
}

int main()
{
	int arr[] = { 1, 2, 2,-4,-6 };
	cout << max(arr, 5);
}