博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
取出无序数组第K大个数(借助快速排序一次划分)
阅读量:4092 次
发布时间:2019-05-25

本文共 601 字,大约阅读时间需要 2 分钟。

#include 
using namespace std;void printArray(int *arr, int size){
for(int i=0; i
= pivot ) {
high--; } array[low] = array[high]; // printArray(array, 7); } array[low] = pivot; // cout<<"pos:"<
<
pos - low + 1) {
return selectK(array, high, pos+1, K-(pos-low+1)); }else{
return selectK(array, pos-1, low, K); }}int main(){
int array[7] = {
10, -22, 211, 120, -2, 23, 120}; int size = sizeof (array) / sizeof (*array); printArray(array, size); cout<<"number:"<

转载地址:http://wecii.baihongyu.com/

你可能感兴趣的文章
Java编程基础:static的用法
查看>>
Java编程基础:抽象类和接口
查看>>
Java编程基础:异常处理
查看>>
Java编程基础:了解面向对象
查看>>
新一代Java模板引擎Thymeleaf
查看>>
Spring MVC中使用Thymeleaf模板引擎
查看>>
Spring Boot构建简单的微博应用
查看>>
Spring处理表单提交
查看>>
Spring MVC异常处理
查看>>
Leetcode 1180. Count Substrings with Only One Distinct Letter [Python]
查看>>
PHP 7 的五大新特性
查看>>
php使用 memcache 来存储 session
查看>>
php实现socket(转)
查看>>
PHP底层的运行机制与原理
查看>>
php 几个比较实用的函数
查看>>
深入了解php底层机制
查看>>
PHP中的stdClass 【转】
查看>>
XHProf-php轻量级的性能分析工具
查看>>
PHP7新特性 What will be in PHP 7/PHPNG
查看>>
比较strtr, str_replace和preg_replace三个函数的效率
查看>>