Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- //#include <algorithm>
- using namespace std;
- int main() {
- int a[] = {3, 4, 5, 1, 6};
- int size = sizeof(a)/sizeof(int);
- //std::sort(&a[0], &a[size]);
- for(int i=0;i<size;i++)
- {
- for(int j=0;j<size;j++)
- {
- if(a[i]>a[j])
- {
- int temp=a[i];
- a[i]=a[j];
- a[j]=temp;
- }
- }
- }
- 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
Advertisement