Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <vector>
- using namespace std;
- int main() {
- int a[] = {3, 4, 5, 1, 6};
- int size = sizeof(a)/sizeof(int);
- std::sort(&a[0], &a[size]);
- double median = size % 2 ? a[size / 2] : (a[size / 2 - 1] + a[size / 2]) / 2;
- cout << median << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment