poj2388
来源:互联网 发布:创维网络电视机 编辑:程序博客网 时间:2024/06/05 14:25
#include<iostream>
#include<string>
using namespace std;
void qsort(int,int);
int arr[10000] = { 0 };
int n = 0;
int main()
{
cin >> n;
int temp;
for(int i=0;i<n;i++)
{
cin >> temp;
arr[i] = temp;
}
qsort(0,n);
cout << arr[n / 2 + 1];
}
void qsort(int l,int r)
{
if(l<r)
{
int i = l, j = r, x = arr[i];
while (i < j)
{
while (i < j&&arr[j] >= x)
j--;
if (i < j)
arr[i++] = arr[j];
while (i < j&&arr[i] <= x)
i++;
if (i < j)
arr[j--] = arr[i];
}
arr[i] = x;
qsort(l, i-1);
qsort(i+1, r);
}
}
#include<string>
using namespace std;
void qsort(int,int);
int arr[10000] = { 0 };
int n = 0;
int main()
{
cin >> n;
int temp;
for(int i=0;i<n;i++)
{
cin >> temp;
arr[i] = temp;
}
qsort(0,n);
cout << arr[n / 2 + 1];
}
void qsort(int l,int r)
{
if(l<r)
{
int i = l, j = r, x = arr[i];
while (i < j)
{
while (i < j&&arr[j] >= x)
j--;
if (i < j)
arr[i++] = arr[j];
while (i < j&&arr[i] <= x)
i++;
if (i < j)
arr[j--] = arr[i];
}
arr[i] = x;
qsort(l, i-1);
qsort(i+1, r);
}
}
阅读全文
1 0
- poj2388
- POJ2388
- poj2388
- poj2388
- poj2388
- poj2388
- poj2388
- poj2388
- poj2388
- POJ2388
- poj2388
- poj2388
- poj2388
- poj2388
- poj2388
- poj2388
- poj2388
- poj2388
- 译:WebRTC视频通信浅析
- CSS字体样式总结
- python是跨平台的 以及 py、pyc、pyo
- js 到 jsp 传输数据
- AngularJS Directive 隔离 Scope 数据交互
- poj2388
- $(document).ready(function()
- spring JPA相关命名规则
- mfc创建office办公软件
- uva-307 sticks
- apache调用php的三种方式及MPM
- CSS文本样式总结
- Eclipse部署Maven web项目到tomcat服务器时,没有将lib下的jar复制过去的解决办法
- 第一天:Androidstudio引入自己的module作为Library(方法跟坑)