文章
49
粉丝
90
获赞
9
访问
27.3k
#include<iostream>
#include<vector>
using namespace std;
vector<int>::iterator new_max_element(vector<int>::iterator a, vector<int>::iterator b)
{
vector<int>::iterator max = a;
for (vector<int>::iterator i = a; i < b; i++)
{
if (*i > *max)
{
max = i;
}
}
return max;
}
vector<int>::iterator new_min_element(vector<int>::iterator a, vector<int>::iterator b)
{
vector<int>::iterator min = a;
for (vector<int>::iterator i = a; i < b; i++)
{
if (*i < *min)
{
min = i;
}
}
return min;
}
int main()
{
int n;
cin >> n;
vector<int> v(n);
for (auto it = v.begin(); it < v.end(); it++)
{
cin >> *it;
}
v.erase(new_max_element(v.begin(), v.end()));
v.erase(new_min_element(v.begin(), v.end()));
for (auto t : v)
{
cout << t << " ";
}
cout << endl;
return 0;
}
登录后发布评论
暂无评论,来抢沙发