11 lines · c
1#pragma once2 3namespace std {4template <class InputIterator, class T>5T accumulate(InputIterator first, InputIterator last, T init) {6 for (; first != last; ++first)7 init = init + *first;8 return init;9}10} // namespace std11 1#pragma once2 3namespace std {4template <class InputIterator, class T>5T accumulate(InputIterator first, InputIterator last, T init) {6 for (; first != last; ++first)7 init = init + *first;8 return init;9}10} // namespace std11