Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Calculate the median
- std::sort(numbers.begin(), numbers.end());
- int median;
- if (numbers.size() % 2 == 0) {
- median = (numbers[numbers.size() / 2 - 1] + numbers[numbers.size() / 2]) / 2;
- } else {
- median = numbers[numbers.size() / 2];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement