#include<iostream>
#include<cstdio>
using namespace std;
int Arr[10000] = { 0 };
void qsort(int Left, int right)
{
int temp = 0;
if (Left >= right) return;
if (right - Left == 1){
if (Arr[Left] > Arr[right]){
temp = Arr[Left];
Arr[Left] = Arr[right];
Arr[right]=temp;
return;
}
else return;
}
int m = Left, n = Left - 1, r = right;
for (; m < r; m++){
if (Arr[m] < Arr[r]){
n++;
temp = Arr[n];
Arr[n] = Arr[m];
Arr[m] = temp;
}
}
n++;
temp = Arr[n];
Arr[n] = Arr[m];
Arr[m] = temp;
qsort(Left, n - 1);
qsort(n + 1, right);
}
int main()
{
int N = 0,i=0;
cin >> N;
for (i = 0; i < N; i++)
cin >> Arr[i];
qsort(0, N - 1);
cout << Arr[N / 2];
return 0;
}
poj2388快排
最新推荐文章于 2021-07-27 18:12:26 发布