You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

19 lines
360 B
C++

#include <iostream>
#include <vector>
using std::cout, std::endl;
int sumEven(const std::vector<int>& v) {
int sum = 0;
size_t s = v.size();
for (int i = 0; i < s; ++i)
if (v[i] % 2 == 0)
sum += v[i];
return sum;
}
int main() {
std::vector<int> v {4, 8, 15, 16, 23, 42};
cout << sumEven(v) << endl;
}