/*
* POJ_2388.cpp
*
* Created on: 2013年10月31日
* Author: Administrator
*/
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 10010;
int main(){
int n;
int a[maxn];
while(scanf("%d",&n)!=EOF){
int i;
for(i = 0 ; i < n ; ++i){
scanf("%d",&a[i]);
}
sort(a,a+n);
printf("%d\n",a[n/2]);
}
return 0;
}
(STL自带的排序功能的使用7.1.2)POJ 2388 Who's in the Middle(sort()函数的使用)
本文介绍如何使用C++实现排序算法,并通过快速排序找到数组的中位数。

被折叠的 条评论
为什么被折叠?



