-
Code double Mean(double x[], int n){ return std::accumulate(x, x + n, 0) / n; }
Test Cases // TODO: Replace examples and use TDD by writing your own tests Describe(any_group_name_you_want) { It(should_do_something) { int n = 4; double x[] = {4,8,4,8}; double mean; mean = Mean(x ,n); Assert::That(6, Equals(mean)); } };
Output:
-
Code #include <iostream>- #include <numeric>
- double Mean(double x[], int n){
double sum = 0;for(int i = 0; i < n; i++){sum += x[i];}return sum / n;- return std::accumulate(x, x + n, 0) / n;
- }
- All
- {{group.name}} ({{group.count}})
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}