Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

各位帮个忙啊,我感觉没有溢出啊(内有简洁代码)

Posted by wanbo at 2009-06-03 21:29:41 on Problem 2623
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,i,a[250001];
    float result;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",a+i);
    sort(a,a+n);
    if(n%2) result=a[(n-1)/2];
    else result=a[n/2]-a[n/2-1]/2.0+a[n/2-1];
    printf("%0.1f\n",result);
    system("pause"); 
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator