#include<iostream>
#include<string>
#include<deque>
#include<vector>
#include<algorithm>
#include<ctime>
using namespace std;
class Person
{
public:
Person(string name,int score)
{
this->m_Score = score;
this->m_Name = name;
}
string m_Name;
int m_Score;
};
void creatPerson(vector<Person>& v)
{
string nameSeed = "ABCDE";
for (int i = 0;i < 5;i++)
{
string name = "选手";
name += nameSeed[i];
int Score = 0;
Person p(name, Score);
v.push_back(p);
}
}
void setScore(vector<Person>& v)
{
for (vector<Person>::iterator it = v.begin();it != v.end();it++)
{
deque<int>d;
for (int i = 0;i < 10;i++)
{
int score = rand() % 41 + 60;
d.push_back(score);
}
for (deque<int>::iterator dit = d.begin();dit != d.end();dit++)
{
cout << (*dit) << " ";
}
cout << endl;
sort(d.begin(), d.end());
d.pop_back();
d.pop_front();
int sum = 0;
for (deque<int>::iterator dit = d.begin();dit != d.end();dit++)
{
sum += *dit;
}
int avg = sum / d.size();
it->m_Score = avg;
}
}
void showcore(vector<Person>& v)
{
for (vector<Person>::iterator it = v.begin();it != v.end();it++)
{
cout << (*it).m_Name << " " << (*it).m_Score;
}
cout << endl;
}
int main()
{
//创建五名选手
srand((unsigned int)time(NULL));
vector<Person>v;
creatPerson(v);
//for (vector<Person>::iterator it = v.begin();it != v.end();it++)
//{
// cout << (*it).m_Name << " " << (*it).m_Score << endl;
//}
//打分
setScore(v);
showcore(v);
}