Skip to content

Commit

Permalink
adding works
Browse files Browse the repository at this point in the history
  • Loading branch information
TodorokiBoy committed Nov 22, 2024
1 parent 3ee01b7 commit 19715b0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions homework/add-even/addEven.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
#pragma once
#include <algorithm>
#include <vector>

int addEven(const std::vector<int>& numbers) {
// TODO: Your implementation goes here
// Below return is only to make this function compile now
return -1;
int result = 0;
std::for_each(numbers.begin(), numbers.end(), [&result](int el) {
if (el % 2 == 0) {
result += el;
}
});

return result;
}

0 comments on commit 19715b0

Please sign in to comment.