(STL自带的排序功能的使用7.1.2)POJ 2388 Who's in the Middle(sort()函数的使用)

来源:互联网 发布:首届人工智能计算大会 编辑:程序博客网 时间:2024/06/08 16:10
/* * 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;}

原创粉丝点击