杭电2014

来源:互联网 发布:c语言程序头文件 编辑:程序博客网 时间:2024/05/17 07:24

注意一下变量的数据类型就行

#include<iostream>

#include<iomanip>
using namespace std;
int main()
{
int n;
while(cin>>n)
{
int i,high=0,low=100;
double sum=0,grade;
for(i=1;i<=n;i++)
{
        cin>>grade;
        sum+=grade;
if(grade>high) high=grade;
if(grade<low) low=grade;
}
sum-=(high+low);
grade=sum/(n-2.0);
cout<<setiosflags(ios::fixed)<<setprecision(2)<<grade<<endl;
}
}