forked from ComputerScienceSoceityNITS/Cpp-debug-24
-
Notifications
You must be signed in to change notification settings - Fork 0
/
StandardDeviation.cpp
32 lines (29 loc) · 904 Bytes
/
StandardDeviation.cpp
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
28
29
30
31
32
// ------------------------COMPLETE THE CODE-----------------------------
#include <bits/stdc++.h>
using namespace std;
double distance(double x1, double y1, double x2, double y2) {
double dx = x2 - x1;
double dy = y2 - y1;
return std::sqrt(dx*dx + dy*dy);
}
double mean(const std::vector<double>& vec) {
double sum = 0.0;
for (double elem : vec) {
sum += elem;
}
return sum / vec.size();
}
double standard_deviation(const std::vector<double>& vec) {
//complete the function
}
int main() {
double d = distance(0.0, 0.0, 1.0, 1.0);
std::cout << "Distance: " << d << std::endl;
std::vector<double> vec = {1.0, 2.0, 3.0, 4.0, 5.0};
double m = mean(vec);
std::cout << "Mean: " << m << std::endl;
double s = standard_deviation(vec);
std::cout << "Standard deviation: " << s << std::endl;
return 0;
}
// ---------------------------ALL THE BEST-----------------------------