def find_maximum(arr):
if not arr:
return None
max_value = arr[0]
for num in arr:
if num > max_value:
max_value = num
return max_value
#include
#include
#include
int find_maximum(const std::vector& arr) {
if (arr.empty()) return std::numeric_limits::min();
int max_value = arr[0];
for (int num : arr) {
if (num > max_value) {
max_value = num;
}
}
return max_value;
}
int main() {
std::vector arr = {1, 5, 3, 9, 2};
std::cout << "Maximum value: " << find_maximum(arr) << std::endl;
return 0;
}