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

附代码吧!so easy!!!

Posted by chenxuan123456789 at 2012-11-04 21:25:18 on Problem 2388
#include <stdio.h>
#include <stdlib.h>
int cmp(const void *_a,const void *_b)
{
    int *a=(int*)_a;
    int *b=(int*)_b;
    return *a-*b;
}
int main()
{
    int *a=NULL,n,m;
    while(scanf("%d",&n)!=EOF)
    {
                              a=(int*)malloc(sizeof(int)*(n+1));
                              for(m=1;m<=n;m++)
                              scanf("%d",&a[m]);
                              qsort(a+1,n,sizeof(a[0]),cmp);
                              n=(n+1)/2;
                              printf("%d\n",a[n]);
    }
    return 1;
}

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