-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample1.cpp
More file actions
35 lines (29 loc) · 754 Bytes
/
Copy pathexample1.cpp
File metadata and controls
35 lines (29 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include <vector>
using namespace std;
int get_vec_val(const vector<int> &vec, size_t index) {
return vec.at(index);
}
int maximum_of_vec(const vector<int> &numbers) {
int current_max = get_vec_val(numbers, 0);
for (size_t j = 1; j < numbers.size(); j++) {
int next_val = get_vec_val(numbers, j);
if (next_val > current_max) {
current_max = next_val;
}
}
return current_max;
}
int main() {
vector<vector<int>> series = {
{ 100, 100, 100, 100, 100 },
{ 0, 0, 0, 0 },
{ },
{ 100, -100, 0 },
{ 6, 147, 210, 93, 104, 44, 180 }
};
for (const auto& v: series) {
cout << maximum_of_vec(v) << endl;
}
return 0;
}