diff options
Diffstat (limited to 'challenge-243/deadmarshal/cpp/ch-2.cpp')
| -rw-r--r-- | challenge-243/deadmarshal/cpp/ch-2.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/challenge-243/deadmarshal/cpp/ch-2.cpp b/challenge-243/deadmarshal/cpp/ch-2.cpp new file mode 100644 index 0000000000..91ab6afe0b --- /dev/null +++ b/challenge-243/deadmarshal/cpp/ch-2.cpp @@ -0,0 +1,21 @@ +#include<iostream> +#include<vector> + +template<typename T> +std::size_t floor_sum(const std::vector<T> &vec) +{ + std::size_t sum{}; + for(std::size_t i{}; i < vec.size(); ++i) + for(std::size_t j{}; j < vec.size(); ++j) + sum += static_cast<std::size_t>(vec.at(i) / vec.at(j)); + return sum; +} + +int main() +{ + std::vector<int> vec1{2,5,9},vec2{7,7,7,7,7,7,7}; + std::cout << floor_sum<int>(vec1) << '\n' + << floor_sum<int>(vec2) << '\n'; + return 0; +} + |
