Re: push_back, square( )ect.ect.
Posted: Sat Apr 04, 2009 8:59 pm
i didnt include the stuff before that generally so not to bore you but i will now make it clear.
it prints the medean line but the if statements must be interupted by the warning.
Code: Select all
#include"stdafx.h"
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
vector<double>temps;
double temp;
while((cin>>temp) && (temps.size() <2))
temps.push_back(temp);
double sum=0;
for (unsigned int i=0;i<temps.size();++i)sum+= temps[i];
cout<<"average temurature: "<<sum/temps.size()<<endl;
sort(temps.begin(),temps.end());
cout<<"medean temurature: "<<temps[temps.size()/2]<<endl;
if(temps[0]<temps[1] && temps[2])
cout<<temps[0]<<" is the least.\n";
else if (temps[1]<temps[0] && temps[2])
cout<<temps[1]<<" is the least.\n";
else
cout<<temps[2]<<" is the least.\n";
cin.clear();
cin.ignore(255, '\n');
cin.get();
return 0;
}