This function of this find the median of three values inside an array. I was wondering if there's a more elegant solution to finding the median value between 3 values.
int mid =((p+r)/ 2);
if(V[p]<V[r]){
if(V[p]<V[mid]){
if(V[mid]<V[r])
swapfunc(V[mid],V[r]);
}
else
swapfunc(V[p],V[r]);
}
else{
if(V[r]<V[mid]){
if(V[p]<V[mid])
swapfunc(V[p],V[r]);
else
swapfunc(V[mid],V[r]);
}
}