Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	for sc.Scan() {
		n, _ := strconv.Atoi(sc.Text())
		scores := make([]int, n, n)
		for i := 0; i < n; i++ {
			sc.Scan()
			scores[i], _ = strconv.Atoi(sc.Text())
		}
		sort.IntSlice(scores).Sort()
		var sum = 0
		for i := 1; i < n-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

C++: #include<iostream>
using namespace std;
int main() {
    while (1) {
        int n; cin >> n;
        if (n == 0) break;
        int sum = 0;
        int max, min;
        for (int i = 0; i < n; ++i) {
            int a; cin >> a;
            if (i == 0) max = min = a;
            max = max < a ? a : max;
            min = min > a ? a : min;
            sum += a;
        }
        sum -= max + min;
        cout << sum / (n - 2) << endl;
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main(void)
{
	int n;
	while(cin >> n, n > 0){
		int s, sum = 0, maxi, mini;
		cin >> s;
		sum += s;
		maxi = s;
		mini = s;
		for(int i = 1; i < n; i++){
			cin >> s;
			sum += s;
			maxi = max(maxi, s);
			mini = min(mini, s);
		}
		cout << (sum-maxi-mini)/(n-2) << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
class Score{
private:
	int shinpan;
	int score[100];
	int max;
	int min;
	int ave;
public:
	Score();
	//????????????????????¨????????????????????¨???
	void Reset();
	//???????????°?????\???
	void InputShinpan(int n){shinpan = n;}
	//?????°??????????????°?????¨?????\?????????
	void InputScore();
	//????????????????????????????????????????????°?????????
	int ReturnAverage();
};
Score::Score(){
	max=INT_MIN;
	min=INT_MAX;
	ave=0;
	shinpan=0;
	for(int i=0;i<100;i++){
		score[i] = INT_MIN;
	}
}
void Score::Reset(){
	max=INT_MIN;
	min=INT_MAX;
	ave=0;
	shinpan=0;
	for(int i=0;i<100;i++){
		score[i] = INT_MIN;
	}
}
void Score::InputScore(){
	for(int i=0;i<shinpan;i++){
		cin >> score[i];
	}
}
int Score::ReturnAverage(){
	for(int i=0;i<shinpan;i++){
		ave += score[i];
		if(score[i]>max){
			max = score[i];
		}
		if(score[i]<min){
			min = score[i];
		}
	}
	ave -= max;
	ave -= min;
	ave = ave / (shinpan - 2);
	return ave;
}
int main()
{
	int n;
	int i;
	Score score;
	while(cin>>n,n!=0){//???????????°?????\??? ?????§??????
		score.InputShinpan(n);
		score.InputScore();
		cout << score.ReturnAverage() << endl;
		score.Reset();
	}
	cin.get();
	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main() {
    int n;
    while (cin >> n && n != 0) {
        if (n == 0) return 0;
        int a[n];
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        sort(a, a + n);
        int ans = 0;
        for (int i = 1; i < n - 1; ++i) {
            ans += a[i];
        }
        cout << ans / (n - 2) << endl;
    }
}

C++: #include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include <climits>

using namespace std;

#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

void solve(){
}

int main(){
  int n;

  while(cin>>n,n){
    int sum = 0;
    int max = INT_MIN;
    int min = INT_MAX;

    rep(i,n){
      int s;
      cin>>s;
      sum += s;

      if(max < s) max = s;
      if(min > s) min = s;
    }

    cout<<(sum - max - min) / (n-2)<<endl;
  }
}

C++: #include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
 
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
 
using namespace std;

int main(){

  while(true){

    int a;
    cin >> a;

    vector<int> list;

    if(a==0){
      break;
    }

    rep(i,a){
      int temp=0;
      cin >> temp;
      list.push_back(temp); 
    }

    sort(list.begin(),list.end());

    int ans=0;
    int count=0;
    REP(i,1,a-1){
      ans+=list[i];
      count++;
    }
    ans=(int)(ans/count);
    cout << ans << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define INF 1e09

using namespace std;

int main(){
  int n;
  int total, maxim, minim;
  int tmp;
  while(cin >> n and n){
    total = 0; maxim = -INF; minim = INF;
    REP(i, n) { cin >> tmp; total += tmp; maxim = max(maxim, tmp); minim = min(minim, tmp); }
    total -= (maxim + minim);
    cout << total / (n - 2) << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  while(1){
    int n;
    cin >> n;
    if(n==0){
      break;
    }
    vector<int> a(n);
    int ma=0;
    int mi=1000;
    int sum=0;
    rep(i,n){
      cin >> a[i];
      ma=max(a[i],ma);
      mi=min(a[i],mi);
      sum+=a[i];
    }
    sum=sum-mi-ma;
    int ave=sum/(n-2);
    cout << ave << endl;
  }
  return 0;
  
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        int n;
        cin >> n;
        if(n == 0) break;
        int maxi = -1;
        int mini = 1e9;
        int sum = 0;
        for(int i = 1; i <= n; i++) {
            int in;
            cin >> in;
            maxi = max(maxi, in);
            mini = min(mini, in);
            sum += in;
        }
        cout << (sum - maxi - mini) / (n - 2) << endl;

    }
    return 0;
}

C++: #include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int main(){
	while(1){
		int N, s, i, sum = 0, maxs = 0, mins = 1001;
		scanf("%d", &N);
		if(N == 0){
			return 0;
		}
		for(i = 0; i < N; i++){
			scanf("%d", &s);
			sum += s;
			maxs = max(maxs, s);
			mins = min(mins, s);
		}
		printf("%d\n", (sum - maxs - mins) / (N - 2));
	}
}

C++: #include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
  int n;
  int po[4000]; 
  while(1)
    {
      cin >> n;
      if(n == 0)break;
      int k;
      for(k=0;k<n;k++)
	{
	  cin >> po[k];
	}
      sort(po,po+k,greater<int>());
      int ans=0;
      for(int i=1;i<k-1;i++)
	{      
	  ans+=po[i];
	}
      cout << floor(ans/(k-2)) << endl;
    }
}

C++: #include <bits/stdc++.h>

using namespace std;
#define all(a)a.begin(),a.end()
const int INF = 1<<30;
const int mod= int(1e9)+7;

int main(){
    while(1){
        int n;cin >>n;
        if(n==0)break;
        int k=n-2;
        int sum=0;
        int mx=-1;int mint=INF;
        for (int i = 0; i < n; ++i) {
            int s;cin >>s;
            mx=max(mx,s);
            mint=min(mint,s);
            sum+=s;
        }
        sum-=(mint+mx);
        cout <<sum/k<<endl;
    }
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main()
{
        while(true)
        {
                int n,A[100]={0};
                cin>>n;
                if(n==0) break;
                rep(i,n) cin>>A[i];
                sort(A,A+n);

                int sum=0;
                rep(i,n-2) sum+=A[i+1];
                cout<<sum/n<<endl;
        }
        return 0;
}