杭电ACM 2014

#include<stdio.h>

int
main()
{

    int
i,n,a[100],max,min;
    double
av,sum;

    while
(scanf("%d",&n)!=EOF)
    {

         for
(i=0;i<n;i++)
        {

            scanf("%d",&a[i]);
        }


        sum=0.0;
        max=a[0];
        min=a[0];


        for
(i=0;i<n;i++)
        {

            if
(a[i]>max)
            {

                max=a[i];
            }

            if
(a[i]<min)
            {

                min=a[i];
           
            }

       
            sum+=a[i];
        }

        av=((sum-max-min)/(n-2));
       
      

           printf("%.2f\n",av);
       
   
    }

   

    return
0;
}

你可能感兴趣的:(ACM)