1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
float Average(const vector<float>& v)
{
float sum = 0.0f;
for (auto& f : v)
sum += f;
return sum / v.size();
}
int main()
{
vector<vector<float>> all_experiments =
{
{23.2, 31, 16.9, 27, 25.4},
{34.8, 45.2, 27.9, 36.8, 33.4},
{19.4, 16.8, 10.2, 20.8, 18.9},
{36.9, 39, 49.2, 45.1, 42.7}
};
cout << fixed << setprecision(2);
for (int i=0; i<all_experiments.size(); ++i)
cout << (i+1) << ": " << Average(all_experiments[i]) << endl;
}
|