英文金曲大赛

英文金曲大赛

Time Limit: 1000 ms  Memory Limit: 65536 KiB

Problem Description

我们在“渊子数”的题目中已经了解了渊子是个什么样的人了,他在大一的时候参加过工商学院的“英语聚乐部”。告诉你个秘密,这个俱乐部是个好地方,不但活动精彩而且有MM。
这不,英语俱乐部举办了一个叫做“英文金曲大赛”的节目。这个节目有好多人参加,这不,成绩出来了,渊子当是很勇敢,自告奋勇接下了算出大家的总得分的任务。 
当时有7个评委,每个评委都要给选手打分,现在要求去掉一个最高分和去掉一个最低分,再算出平均分。结果精确到小数点后两位。

Input

测试数据包括多个实例。
每组数据包括7个实数,代表评委们对该选手的评分。紧接着是选手的名字,名字的长度不超过30个字符,且没有空格。 
输入直到文件结束。

Output

算出每位选手名字和最终得分,结果保留两位小数。

Sample Input

10 10 10 10 10 10 9 xiaoyuanwang
0 0 0 0 0 0 0 beast

Sample Output

xiaoyuanwang 10.00
beast 0.00

Hint

 

Source

ZJGSU

AC代码

#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
struct s
{
double score[8];
char name[100];
};
int main()
{
struct s p[1000];
int i=0;
while(scanf("%lf %lf %lf %lf %lf %lf %lf %s",&p[i].score[0],&p[i].score[1],&p[i].score[2],&p[i].score[3],&p[i].score[4],&p[i].score[5],&p[i].score[6],p[i].name)!=EOF)
{
double sum=0,max=p[i].score[0],min=p[i].score[0],aver;
for(int j=0;j<7;j++)
{
sum+=p[i].score[j];
max=(p[i].score[j]>max)?p[i].score[j]:max;
min=(p[i].score[j]<min)?p[i].score[j]:min;
}
sum-=(max+min);
aver=sum/(double)5;
printf("%s %.2lf\n",p[i].name,aver);
i++;
}
return 0;
}

猜你喜欢

转载自blog.csdn.net/yt201758501112/article/details/80777399