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

为什么WA?????????不理解

Posted by bootshl at 2008-07-31 16:37:30 on Problem 3325
#include <stdio.h>
#include <stdlib.h>

int cmp(const void* e1, const void* e2);

int main(void)
{
    int n, a[1001], i, count;
    double sum, ave[101];
    count = 0;
    while (scanf("%d", &n) == 1 && n) {
        for (i = 0; i < n; i++)
            scanf("%d", a + i);
        qsort(a, n, sizeof(int), cmp);
        sum = 0;
        for (i = 1; i < n-1; i++)
            sum += a[i];
        ave[count++] = sum/(n - 2);
    }
    for (i = 0; i < count; i++)
        printf("%.0lf\n", ave[i]);
    return 0;
}

int cmp(const void* e1, const void* e2)
{
    return (*(int*)e1) - (*(int*)e2);
}

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