include iostream using namespace std double average double array int i

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#include <iostream>
using namespace std;
double average(double array, int n) {
if (n == 1) {
return array[n - 1];
} else {
return ((n - 1) * average(array, n - 1) + array[n - 1]) / n;
}
}
int main() {
double array[6] = {1, 2, 3, 5, 7, 8};
cout << average(array, 6);
}