You are viewing a single comment's thread. Return to all comments →
using namespace std;
int findMedian(int arr[], int n) { sort(arr, arr + n); return arr[n / 2]; }
int main() { int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; }
cout << findMedian(arr, n) << endl; return 0;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Find the Median
You are viewing a single comment's thread. Return to all comments →
include
include
using namespace std;
int findMedian(int arr[], int n) { sort(arr, arr + n); return arr[n / 2]; }
int main() { int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; }
}