Find the Median

  • + 0 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]; }

    cout << findMedian(arr, n) << endl;
    
    return 0;
    

    }