问题及代码
/*
*作者:李长鸿
*时间:2014.11.03
*问题描述:计算选手参加比赛得分
*问题输入:评委打分
*问题输出:选手得分
*/
#include <iostream>
using namespace std;
int main()
{
int i,j;
double a=0,b=10,c=0.0,x,grade;
cin>>j;
cout<<endl;
cin>>x;
if(x<=10&&x>=0)
{
for(i=1; i<=j; i++)
{
c+=x;
if(a<=x)
a=x;
if(b>=x)
b=x;
cout<<"第"<<i<<"位评委给分: "<<x<<endl;
if(i>=j) break;
cin>>x;
}
grade=(c-a-b)/(j-2);
cout<<"减去一个最高分"<<a<<","<<"减去一个最低分"<<b<<"."<<endl;
cout<<"当前选手的最后得分为"<<grade<<endl;
}
else cout<<"输入有误,请重新输入"<<endl;
return 0;
}