How can i find the median from a vector with even number of values?

So ive been working on a C++ project for my college course for a few days now where we need to input an unknown amount of numbers into a vector and then find the min, max and median values. so i havent had any trouble with inputting the values or finding the min or max, but for the median i have been having trouble. i can easily determine it if the amount of values in the vector is odd because with the vector sorted, the median is simply vector.size()/2. But i have no idea how to figure it out if its an even set of numbers because that would mean taking the 2 middle values, adding them, and dividing by 2 and im not sure how to find the 2 middle values.

but anyways sorry for rambling, could someone please help me out? Thanks in advance
If vector.size() is even, the middle two values are at vector.size()/2 and vector.size()/2-1.
Topic archived. No new replies allowed.