fork download
  1. #include <iostream>
  2. #include <numeric>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8. vector<double> vd{5.0,9.9,2.0,3.6,7.1,8.0,4.5};
  9. double avg = std::accumulate(vd.begin(), vd.end(), 0.0)/vd.size();
  10. cout << avg << endl;
  11. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
5.72857