poj2388解题报告(排序)

 

 

 

POJ 2388,题目链接http://poj.org/problem?id=2388

题意:

水题一道

给定n个数,输出中间值,可以用sort,干脆快捷

代码:

//396K	32MS
#include <cstdio>
#include <algorithm>

int buf[10000];

int main()
{
	int cowsNum;
	scanf("%d", &cowsNum);

	int temp;
	for (int i=0; i<cowsNum; ++i)
	{
		scanf("%d", &temp);
		buf[i] = temp;
	}
	std::sort(buf, buf+cowsNum);
	printf("%d\n", buf[cowsNum/2]);

	return 0;
}

 

 

 

 

 

posted @ 2014-06-15 18:49  、拂晓  阅读(224)  评论(0编辑  收藏  举报