123456789101112131415161718192021
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { vector<double> temps; double temp; while (cin>>temp) temps.push_back(temp); double sum = 0; for (int i = 0; i<temps.size();++i)sum += temps[i]; cout<<"average temperature: "<<sum/temps.size()<<endl; sort(temps.begin(),temps.end()); cout<<"Median temperature:" <<temps[temps.size()/2]<<endl; }
12
while (cin>>temp) temps.push_back(temp);
123
while (cin>>temp && temp != 0){ temps.push_back(temp); }
1234
do { temps.push_back(temp); } while (cin>>temp && temp != 0);