# STL案例
有5名选手,选手ABCED,10个评委打分,去除最高分和最低分得到平均分
```
#include<iostream>
#include<string>
#include<vector>
#include<deque>
#include<random>
#include<algorithm>
#include<ctime>
using namespace std;
int main()
{
srand(time(NULL));
deque<int> rank1;
deque<int> rank2;
deque<int> rank3;
deque<int> rank4;
deque<int> rank5;
vector<deque<int>> player;
vector<double> sum;
//给每个选手的评分赋初值
for (int i = 0; i < 10; i++)
{
int temp = rand() % 100;
rank1.push_back(temp);
rank2.push_back(temp);
rank3.push_back(temp);
rank4.push_back(temp);
rank5.push_back(temp);
}
player.push_back(rank1);
player.push_back(rank2);
player.push_back(rank3);
player.push_back(rank4);
player.push_back(rank5);
for (int i = 0; i < 5; i++)//排序
{
sort(player[i].begin(), player[i].end());
}
for (int i = 0; i < 5; i++)//删除第一个和最后一个
{
player[i].pop_back();
player[i].pop_front();
double avg = 0;
double end=0;
for (int j = 0; j < player[i].size(); j++)//求均值
{
end += player[i][j];
}
avg = end / player[i].size();
sum.push_back(avg);
}
//打印结果
for (int i = 0; i < 5; i++)
{
cout << sum[i] << endl;
}
//for (vector<double>::iterator begin = sum.begin();begin != sum.end(); begin++)
//{
// cout << *begin << endl;
//}
return 0;
}
```