#include\x20 #include\x20 #include\x20 #include\x20

using\x20namespace\x20std;

int\x20main()\x20{ \x20\x20int\x20N, k, M; \x20\x20cin\x20>>\x20N\x20>>\x20k\x20>>\x20M;

\x20\x20vector\x20scores(N);\x20//\x20保存每个学生的成绩

\x20\x20//\x20输入每个学生的成绩 \x20\x20for\x20(int\x20i\x20=\x200; i\x20<\x20N; i++)\x20{ \x20\x20\x20\x20vector\x20temp(k);\x20//\x20保存每个学生的k个评审成绩 \x20\x20\x20\x20for\x20(int\x20j\x20=\x200; j\x20<\x20k; j++)\x20{ \x20\x20\x20\x20\x20\x20cin\x20>>\x20temp[j]; \x20\x20\x20\x20} \x20\x20\x20\x20//\x20去掉一个最高分和一个最低分,求剩下分数的平均值 \x20\x20\x20\x20sort(temp.begin(), temp.end()); \x20\x20\x20\x20double\x20sum\x20=\x200; \x20\x20\x20\x20for\x20(int\x20j\x20=\x201; j\x20<\x20k\x20-\x201; j++)\x20{ \x20\x20\x20\x20\x20\x20sum\x20+=\x20temp[j]; \x20\x20\x20\x20} \x20\x20\x20\x20scores[i]\x20=\x20sum\x20/\x20(k\x20-\x202); \x20\x20}

\x20\x20//\x20按非递减顺序输出最后得分最高的M个成绩 \x20\x20sort(scores.begin(), scores.end(), greater()); \x20\x20for\x20(int\x20i\x20=\x200; i\x20<\x20M; i++)\x20{ \x20\x20\x20\x20cout\x20<<\x20fixed\x20<<\x20setprecision(3)\x20<<\x20scores[i]\x20<<\x20"\x20"; \x20\x20} \x20\x20cout\x20<<\x20endl;

\x20\x20return\x200; }

C++ 实现学生互评作业评分系统:去除最高最低分求平均

原文地址: https://www.cveoy.top/t/topic/pCBl 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录