// Code derived from Stroustrup's PPP2 book// § 4.6.3 A numeric example// -and beginning on p 122#include<algorithm>#include<iostream>#include<vector>usingstd::cin;usingstd::cout;usingstd::vector;template<typenameC>voidsort(C&c){std::sort(begin(c),end(c));}// compute mean and median temperaturesintmain(){cout<<"Please enter temperatures: ";vector<double>temps;// temperaturesfor(doubletemp;cin>>temp;)// read into temptemps.push_back(temp);// put temp into vector// compute mean temperature:doublesum=0;for(doublex:temps)sum+=x;cout<<"Average temperature: "<<((temps.size()>0)?(sum/temps.size()):0)<<'\n';// compute median temperature:sort(temps);// sort temperaturescout<<"Median temperature: "<<((temps.size()>0)?(temps[temps.size()/2]):0)<<'\n';}