-
Code fn mean(x: &[u64]) -> u64 { x.iter().sum::<u64>() / x.len() as u64 }
Test Cases fn test() { assert_eq!(mean(&[4, 8, 4, 8]), 6); }
Output:
-
Code #include <iostream>double Mean(double x[], int n){double sum = 0;for(int i = 0; i < n; i++){sum += x[i];}return sum / n;}- fn mean(x: &[u64]) -> u64 {
- x.iter().sum::<u64>() / x.len() as u64
- }
Test Cases // TODO: Replace examples and use TDD by writing your own testsDescribe(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));}};- #[test]
- fn test() {
- assert_eq!(mean(&[4, 8, 4, 8]), 6);
- }
- 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 }}