Question
Hello, How should I go about this assignment? Thanks for any help! Assignment: Finish the 3 stub functions in the linked file. Do not use
Hello,
How should I go about this assignment?
Thanks for any help!
Assignment:
Finish the 3 "stub" functions in the linked file.
Do not use any built-in mean, median or std. deviation functions in C++.
#include
#include
#include
#include
using namespace std;
double mymedian(vector
{
}
double mymean(vector
{
}
double mystdev(vector
{
}
double mymin(vector
{
double out = in[0];
for (int i=1; i { if (in[i] < out) { out = in[i]; } } return out; } double mymax(vector { double out = in[0]; for (int i=1; i { if (in[i] > out) { out = in[i]; } } return out; } void display(vector { for (int i=0; i { cout << in[i] << " "; } cout << endl; } int main() { ifstream fin("feb12.txt"); vector double tmp; fin >> tmp; while ( not fin.fail() ) { list.push_back(tmp); fin >> tmp; } display(list); cout << "min: " << mymin(list) << endl; cout << "max: " << mymax(list) << endl; cout << "mean: " << mymean(list) << endl; cout << "stdev: " << mystdev(list) << endl; sort(list.begin(), list.end()); cout << "sorted: "; display(list); cout << "median: " << mymedian(list) << endl; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started