fork download
  1. #include <array>
  2. #include <numeric>
  3. #include <iostream>
  4. int main()
  5. {
  6. std::array<int, 5> a = {1, 3, 5, 7, 9};
  7. int tage = 0;
  8.  
  9. auto it = a.begin();
  10. int sum = std::accumulate(it, it+3, tage);
  11.  
  12. std::cout << sum << '\n';
  13. }
  14.  
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
9