hello pals,
I'vw want to re-write this function:
template<class T> T median(vector<T> v)
{
typedef type name vector<T>::size_type vec_sz;
vec_sz size =3D v.size();
if (size =3D=3D 0)
throw domain_error("median of empty vector");
=20
sort(v.begin(), v.end());
vex_sz mid =3D size/2;
return size % 2 =3D=3D 0 ? (v[mid] + v[mid-1]) / 2 : v[mid];
}
so that i can call it with either a vector or a built-in array. I want =
it to allow containers of any arithmetic type.
thnx
napoleon.
|