fork download
  1. #include <numeric>
  2. #include <iostream>
  3. #include <vector>
  4.  
  5. int main() {
  6. double v[] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
  7. double avg = std::accumulate(std::begin(v), std::end(v), 0.0) / (std::end(v) - std::begin(v));
  8. std::cout << avg << std::endl;
  9. return 0;
  10. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
3.5