nth_element:运用一趟快速排序思想,把第n小(从0开始)的数放在下标为n的位置(从0开始).

nth_element(start,start+n,end);

例子:

STL中nth_element用法

结果:

STL中nth_element用法

第3小的为4(从0开始),,第0小的为1,第1小的为2,,,

注意:1、第几小的是从0开始的,最小的是第0小的

2、使第n小的放在下标为n的位置,不是使第n大的放该位置

 

相关文章:

  • 2022-12-23
  • 2021-09-18
  • 2022-02-08
  • 2022-02-25
  • 2021-11-15
猜你喜欢
  • 2022-12-23
  • 2021-10-10
  • 2022-12-23
  • 2022-12-23
  • 2021-07-16
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案