POJ 2388 Who's in the Middle(排序)

//快排水题,练习STL的QSORT #include<iostream> using namespace std; int arr[10010]; int cmp(const void *a, const void *b) { int *A = (int*)a; int *B = (int*)b; return *A - *B; } int main() { int n; cin >> n; for(int i = 0;i < n;++i) cin >> arr[i]; qsort(arr,n,sizeof(arr[0]),cmp); cout << arr[n/2] << endl; return 0; } 

你可能感兴趣的:(POJ 2388 Who's in the Middle(排序))