Ciyeblog - STL https://www.ciyekua.cn/index.php/category/STL/ 接触到的STL库函数统计 https://www.ciyekua.cn/index.php/diary/153.html 2024-08-15T18:35:00+08:00 1.nth_element() 2024/08/15 作用:找出数组中第k小的数 > https://www.ciyekua.cn/index.php/diary/152.html 利用stl中nth_element()找出第k小的数字 https://www.ciyekua.cn/index.php/diary/152.html 2024-08-15T18:28:00+08:00 找出一个数组中第k小的数 一、朴素做法 sort() 时间复杂度:O(nlogn) 二、利用STL库函数nth_element() 时间复杂度:O(n) 用法:`nth_element(a,a+k,a+n)` 长度为n的数组a[]中找出第k小的数