3.4.1 案例描述
有5名选手:选手ABCDE,10个评委分别对每一名选手打分,去除最高分,去除评委中最低分,取平均分。
自己做的
#include<iostream>
#include<deque>
#include<algorithm>
#include<time.h>
using namespace std;
class Person
{
public:
Person(string name, int score)
{
this->m_Name = name;
this->m_score = score;
}
string m_Name;
int m_score;
};
void test()
{
deque<Person>d;
Person p1("A", 0);
Person p2("B", 0);
Person p3("C", 0);
Person p4("D", 0);
Person p5("E", 0);
d.push_back(p1);
d.push_back(p2);
d.push_back(p3);
d.push_back(p4);
d.push_back(p5);
srand((unsigned int)time(NULL));
for (int i = 0; i < 5; i++)
{
deque<int>k;
for(int j = 0; j < 10; j++)
{
int score = rand() % 41 + 60;
k.push_back(score);
}
sort(k.begin(),k.end());
k.pop_back();
k.pop_front();
int num = 0;
for (int a = 0;