L2-015. 互评成绩
学生互评作业的简单规则是这样定的:每个人的作业会被k个同学评审,得到k个成绩。系统需要去掉一个最高分和一个最低分,将剩下的分数取平均,就得到这个学生的最后成绩。本题就要求你编写这个互评系统的算分模块。
输入格式:
输入第一行给出3个正整数N(3< N <= 104,学生总数)、k(3<= k <= 10,每份作业的评审数)、M(<= 20,需要输出的学生数)。随后N行,每行给出一份作业得到的k个评审成绩(在区间[0, 100]内),其间以空格分隔。
输出格式:
按非递减顺序输出最后得分最高的M个成绩,保留小数点后3位。分数间有1个空格,行首尾不得有多余空格。
输入样例:6 5 3 88 90 85 99 60 67 60 80 76 70 90 93 96 99 99 78 65 77 70 72 88 88 88 88 88 55 55 55 55 55输出样例:
87.667 88.000 96.000
L2里面的水题就是排下序找出前后删除然后做就行很简单!!!!!!!!
# include <iostream>
# include <algorithm>
# include <set>
# include <map>
# include <vector>
# include <queue>
# include <numeric>
# include <string>
# include <cstring>
# include <iomanip>
# include <cstdio>
# include <functional>
//# include <bits/stdc++.h>
using namespace std;
struct Mycompare
{
bool operator()(double a, double b)
{
if(a > b)
{
return true;
}
else
{
return false;
}
}
};
int main()
{
int n, m, k;
while(cin >> n >> k >> m)
{
double b[10005] = {0};
int t = 0;
while(n--)
{
double a[10005] = {0};
// double l;
for(int i = 0; i < k; i++)
{
cin >> a[i];
}
sort(a, a + k);
a[0] = a[k - 1] = 0;
// v1.pop_back();
// v1.pop_front();
// cout << "size = " << v1.size() << endl;
double pos = accumulate(a , a + k, 0);
double ave = pos / (k - 2);
b[t++] = ave;
}
int p = 0;
sort(b, b + t , greater<double>() );
for(int i = m -1; i >= 0; i--)
{
if(p)
cout << " ";
p = 1;
cout << setiosflags(ios::fixed) << setprecision(3) << b[i];
}
cout << endl;
}
return 0;
}