Question
//program 4.6.3 below int main() { vector temps; // temperatures for (double temp; cin>>temp; ) // read into temp temps.push_back(temp); // put temp into vector
//program 4.6.3 below
int main()
{
vector
for (double temp; cin>>temp; ) // read into temp
temps.push_back(temp); // put temp into vector
// . . . do something . . .
}
double temp;
while (cin>>temp) // read
temps.push_back(temp); // put into vector
// temp might be used here
// compute mean and median temperatures
int main()
{
vector
for (double temp; cin>>temp; ) // read into temp
temps.push_back(temp); // put temp into vector
// compute mean temperature:
double sum = 0;
for (int x : temps) sum += x;
cout
// compute median temperature:
sort(temps); // sort temperatures
cout
}
// compute average temperature:
double sum = 0;
for (int x : temps) sum += x;
cout
// compute median temperature:
sort(temps); // sort temperatures
cout If we define the median of a sequence as "a number so that exactly as t in the sequence as come after it," fix the at it always prints out a median. Hint: A median need not be an element of the sequen ce
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