POJ2388#快排水题
来源:互联网 发布:一键领取cf装备源码 编辑:程序博客网 时间:2024/04/26 00:15
#include <iostream>using namespace std;void quickSort(int seq[], int begin, int end){if (begin < end){int temp = seq[begin];//挖坑int i = begin;int j = end;while (i < j){while (i < j && seq[j] > temp)//从后往前找到小于temp的数{j--;}if (i < j){seq[i++] = seq[j];}while (i < j && seq[i] < temp)//从前往后找到大于temp的数{i++;}if (i < j){seq[j--] = seq[i];}}//将之前挖出来的数放到适合的位置seq[i] = temp;//递归quickSort(seq, begin, i - 1);quickSort(seq, i + 1, end);}}int main(){int n;cin >> n;int seq[99999];for (int i = 0; i < n; i++){cin >> seq[i];}quickSort(seq, 0, n - 1);cout << seq[(n - 1) / 2] << endl;}
0 0
- POJ2388#快排水题
- poj2388快排
- POJ2388-排序水题
- poj2388
- POJ2388
- poj2388
- poj2388
- poj2388
- poj2388
- poj2388
- poj2388
- poj2388
- POJ2388
- poj2388
- poj2388
- poj2388
- poj2388
- poj2388
- 伟哥忽然听见同样健康与苦与
- 人脸检测 训练方法
- oracle10G em dbconsole无法启动
- C学习笔记——malloc内存分配
- Evaluate Reverse Polish Notation--逆波兰式求值
- POJ2388#快排水题
- cc150:从一个未排序的链表中移除重复项
- 解决加载图片OOM 方法汇总
- Windows8下安装SQL Server 2005无法启动服务的解决办法
- Javascript事件模拟(鼠标事件、键盘事件)
- 在CubieTruck中安装jdk
- 【大数模板】
- Semaphores 博客开通
- 自定义description方法与debugDescription方法