#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
vector <int> scores;
int score;
while(cin>>score)//一直跳不出来,循环输入
{
scores.push_back(score);
}
sort(scores.begin(),scores.end());
scores.pop_back();
scores.erase(scores.begin());
int sum=0;
for(int i=0;i<scores.size();i++) sum=sum+scores[i];
int average;
average=sum/scores.size();
cout<<average<<endl;
return 0;
}
更改:
cin >> score;
while (score)
{
scores.push_back(score);
cin >> score;
}
(当做自己的笔记了)