题目链接:http://poj.org/problem?id=2388
题目难度:水题
题目概括:输入个数N,再输入N个数字,找出大小处于中心的数字,要求左边的数字全部比中心的小,右边的都要比中心的大。
题解:无难度,将输入内容传入数组内,再用sort()函数对数组进行排序,之后在输出排序后的“中间值”(我的数组是从0开始,所以中间值=(int)总长度/2)
下面就是我的代码了:
#include <iostream>
#include <algorithm>
#include<stdio.h>
using namespace std;
int s[10005];
int main()
{
int a,b;
scanf("%d",&a);
for(int i=0;i<a;i++)
{
scanf("%d",&s[i]);
}
sort(s,s+a);
b=a/2;
printf("%d\n",s[b]);
}