I have a simple code which gets a median form a file of intigers.

Here is part of it:

Code:

int total = 0 ;
int number = 0;
int middle;
for (int i ; intiger_stream >> number ; i ++ )
{
total ++ ;
}
middle = (total + 1)/2 ;
cout << "Median : " << middle << endl;

It works fine, but I heard that a better way of finding a median is by passing through the intigers in the file twice, first getting the total intigers and on the second pass getting an intiger in the middle (the median).

I can't figureout how to find the median via that second method.

Could someone give me a hint.

Thanks