One way to go about it would be to first sort the numbers from lowest to highest. Then, since you know there are exactly five numbers, the third must be the median.
Your problem then becomes sorting the numbers; finding the median is simple after that's done.
Sorting is a very common task. Try a forum search for some pointers.
Sorting is even so common that the STL contains a function called sort, so you should be able to simply type
to sort your array named a with the 5 numbers. Unless you really want to do the sorting by yourself (which is a good exercise!), I would always prefer the STL algorithms.