Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #if defined(_MSC_VER)
- #include <__msvc_all_public_headers.hpp>
- #elif defined(__GNUC__)
- #include <bits/stdc++.h>
- #else
- #error "Unsupported compiler"
- #endif
- using namespace std;
- template <typename T, size_t size>
- T sum(T(&arr)[size]) {
- T s = 0;
- for (size_t i = 0; i < size; i++) {
- s += arr[i];
- }
- return s;
- }
- int main() {
- int arr[] = { 1, 2, 3, 4, 5 };
- cout << sum(arr) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement