题目描述
blablabla
样例
#include <iostream>
using namespace std;
void qsort(int A[], int begin, int end) {
if (begin >= end)
return;
int x = A[(begin + end) / 2];
int tmp = 0;
int left = begin - 1, right = end + 1;
while (left < right) {
do left++; while (A[left] < x);
do right--; while (A[right] > x);
if (left < right) {
tmp = A[right];
A[right] = A[left];
A[left] = tmp;
}
}
qsort(A, begin, right);
qsort(A, right + 1, end);
}
int main() {
int n, k;
scanf("%d", &n);
scanf("%d", &k);
int A[n];
for (int i = 0; i < n; i++) scanf("%d", &A[i]);
qsort(A, 0, n - 1);
printf("%d", A[k - 1]);
}
算法1
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla
算法2
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla