Go: package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for {
		num := nextInt(sc)
		if num == 0 {
			break
		}

		score_list := []int{}
		for i := 0; i < num; i++ {
			score_list = append(score_list, nextInt(sc))
		}
		// 得点リストをソートした後、最低点と最高点を取り除く(3 ≤ n ≤ 100)
		sort.Sort(sort.IntSlice(score_list))
		score_list = score_list[1 : len(score_list)-1]
		// 得点リストの得点を合計し、スライスの個数で割って平均点を出す
		sum := 0
		for _, score := range score_list {
			sum += score
		}
		fmt.Println(sum / len(score_list))
	}
}

C++: #include<bits/stdc++.h>
using namespace std;

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

    return 0;
}

C++: #include<stdio.h>
#include<iostream>
using namespace std;
int main() {
	int a;
	while (cin >> a, a) {
		int sum=0; 
		int d;
		int f;
		int e = 0;
		for (int i = 0; i < a; i++) {
			cin >> d;
			if (i == 0) {
				f = d;
				e = d;
			}
			if (d > e) {
				e = d;
			}
			if (f > d) {
				f = d;
			}
			sum += d;
		}
		sum = sum - (e + f);
		sum = sum / (a-2);
		cout << sum << endl;
	}
}

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

using namespace std;
typedef long long ll;

int main(){
    
    ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    while(n){
        int a[n];
        int mini = INT_MAX, maxi = INT_MIN;
        int mincnt=0, maxcnt=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
            mini = min(mini, a[i]);
            maxi = max(maxi, a[i]);
        }
        for(int i=0;i<n;i++){
            if(a[i]==mini)  mincnt++;
            else if(a[i]==maxi) maxcnt++;
        }
        //cout<<mini<<" "<<mincnt<<" "<<maxi<<" "<<maxcnt<<endl;
        int sum=0;
        int cnt=0;
        for(int i=0;i<n;i++){
            if(a[i]==mini && mincnt>1){
                sum +=a[i];
                cnt++;
                mincnt--;
            }
            else if(a[i]==maxi && maxcnt>1){
                sum +=a[i];
                cnt++;
                maxcnt--;
            }
            else if((a[i]!=mini) && (a[i]!=maxi)){
                sum +=a[i];
                cnt ++;
            }
        }
        cout<<sum/cnt<<endl;
        cin>>n;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int judge;
int maxscore =0;
int minscore =0;
int maxnum=0;
int minnum=0;
cin >> judge;
int score[judge];
	for(int i=0; i<judge; i++){
	cin >> score[i];
		if(score[i] > maxscore){
		maxscore = score[i];
		maxnum=i;
		}
		if(score[i] < minscore){
		minscore = score[i];
		minnum=i;
		}
	}
score[maxnum] = 0;
score[minnum] = 0;
int lastscore = 0;
for(int j=0;j<judge;j++){
lastscore = lastscore +  score[j];
}
lastscore = lastscore/(judge - 2);
cout << lastscore <<endl;
return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<random>
#include<string>
typedef long long ll;
using namespace std;
int main(){
  ll N;
  ll s[1100];
  ll sum=0;
  ll t=0;
  while(t<=20){
  t++;
  cin >> N;
  for(ll i = 0; i < N; ++i){
      cin >> s[i];
  }
  sort(s,s+N);
  for(ll i = 1; i < N-1; ++i){
    sum+=s[i];
  }
  cout<<sum/(N-2)<<endl;
}
}

C++: #include <iostream>
#include <queue>
using namespace std;

int main(int argc, char const *argv[]){
	int n;
	priority_queue<int> que;

	while(1){
		int total = 0;
		int i;
		cin>>n;
		if (n==0) break;
		for (int i = 0; i < n; i++){
			int tmp;
			cin>>tmp;
			que.push(tmp);
		}
		que.pop();
		int m = que.size()-1;
		for (i = 0; i < m; i++){	
			total += que.top();
			que.pop();
		}
		cout<<total/i<<endl;
		que.pop();
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main (){
    while(true){
    int n;
    cin >> n;
    int max=0;
    int min = 10000;
    int sum = 0;
    int x;
    int count =0;
    
    if(n==0)return 0;
    for(int i=0;i<n;i++){
        cin >> x;
        if(min>x)min=x;
        if(max<x)max=x;
        sum = sum + x;
        count++;
    }
    int average;
    average = (sum -min -max)/(count-2);
    cout << average << endl;
    }

}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int main(){
    while(true){
        int n; cin >> n; if(n ==0 ) break;
        int sum = 0; int cou = 0;
        vi v(n,INF);
        rep(i,n){cin >> v[i];}

        sort(v.begin(),v.begin()+n);
        v.erase(v.begin());
        v.erase(v.end()-1);
        rep(i,n-2){
            sum+=v[i]; cou++;
        }
        cout << sum /cou << endl;
    }
}

C++: #include <iostream>
#include <algorithm>
using namespace std;

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