Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- const int SIZE = 5;
- double median(int *, int);
- int main(){
- int Num[SIZE] = {5, 10, 15, 20, 25};
- int *nList = Num;
- cout << "The median is: " << median(nList, SIZE) << "\n";
- return 0;
- }
- double median(int *array, int SIZE){
- int mid = (SIZE - 1) / 2;
- double med;
- if (SIZE % 2 == 0){
- med = (*(array + mid) +*(array + (mid + 1))) / 2;
- }
- else
- med = *(array + mid);
- return med;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement