📌  相关文章
📜  在数组中查找第 k 个最大和最小元素 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:53.138000             🧑  作者: Mango

代码示例1
#include  
using namespace std;

int main(){
      const int size = 10;
      int k = 3; //Can be any number smalled than size
    int array[size] = {5,2,8,34,73,82,1,6,19,29};
    sort(array,array+size);
    int smallestKthElement = array[k-1];    
    int largestKthElement = array[size-k];
}