不明白为什么程序会崩溃,找不出问题
#include<iostream>
#include<vector>
#include<deque>
#include<string>
#include<algorithm>
using namespace std;
//1.创建person对象将其放入vector容器中
class person
{
public:
person(int score,string name)
{
this->m_name = name;
this->m_score = score;
}
int m_score;
string m_name;
};
void putperson(vector<person>&v)
{
string nameseed = "ABCDEF";
for (int i = 0; i < 6; i++)
{
string name = "选手";
name += nameseed[i];
int score = 0;
person p(score, name);
v.push_back(p);
}
}
void setscore(vector<person>& v)
{
for (vector<person>::iterator it = v.begin(); it != v.end(); v.begin()++)
{
deque<int> p;
for (int i = 0; i < 10; i++)
{
int score = rand() % 40 + 61;
p.push_back(score);
}
sort(p.begin(),p.end());
p.pop_back();
p.pop_front();
int sum=0;
for (deque<int>::iterator it; it != p.end(); it++)
{
sum += *it;
}
int average = sum / 8;
it->m_score = average;
}
}
void test()
{
vector<person>p;
putperson(p);
//创建6个人
//并将六个人放入vector容器中
setscore(p);
//打分
//去掉一个最高一个最低
//取平均分作为最终成绩
for (vector<person>::iterator it = p.begin(); it != p.end(); it++)
{
cout << "姓名 " << it->m_name << " 分数:" << it-> m_score << endl;
}
}
int main()
{
test();
system("pause");
return 0;
}
```