| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
改了一下你的代码就AC了In Reply To:求助 我用nth_element() 为什么 不行 请帮忙 老Wa Posted by:goldenking at 2006-05-05 13:48:29 注意C语言里,数组的下标是从0开始的,a[5]这个数组中的中间元素是a[2],不是a[3].
Source
Problem Id:2388 User Id:Sempr
Memory:116K Time:76MS
Language:C++ Result:Accepted
Source
#include<iostream>
#include<fstream>
#include<algorithm>
#define MAXN 10000
using namespace std;
int main()
{
long int milk[MAXN], N;
long int result;
int i;
while(cin>>N)
{
for(i=0;i<N;i++)
cin>>milk[i];
result=N/2;
nth_element(milk, milk + result, milk + N);
cout<<milk[result]<<endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator