Go: package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	for n != 0 {
		arr := make([]int, n)
		for i := range arr {
			fmt.Scan(&arr[i])
		}
		sort.Ints(arr)

		sum := 0
		for i := 1; i < len(arr)-1; i++ {
			sum += arr[i]
		}
		fmt.Println(sum / (n - 2))
		fmt.Scan(&n)
	}
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	int max;
	int min;
	int y[20] = { 0 };

	n = 1;
		int j = 0;
		while (1){
			
			cin >> n;
			if (n == 0) break;
			max = 0;
			min = 1000;
			for (int i = 0; i < n; i++){
				int x[1000] = { 0 };
				cin >> x[i];

				if (max < x[i]) max = x[i];
				if (min > x[i]) min = x[i];
				y[j] += x[i];
			}
			y[j] = y[j]-max - min;
			y[j] = y[j] / (n - 2);
			j++;
		}
	for (int k = 0; k < j; k++){
		cout << y[k]<< endl ;
	}
	return 0;
}

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

void score(int x){
    int n;
    int point[21];
    int ave = 0;

    n = x;
    for(int i=0;i<n;i++) cin >> point[i];
    sort(point,point+n);
    for(int i=1;i<n-1;i++){
        ave += point[i];
    }
    cout << ave / (n - 2) << endl;
}

int main(){
    int x;
    while(x != 0){
        cin >> x;
        score(x);
    }
    
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		int a=10000,b=-1,sum=0;
		for(int i=0;i<n;i++){
			int s;
			cin>>s;
			sum+=s;
			a=min(a,s);
			b=max(b,s);
		}
		cout<<(sum-a-b)/(n-2)<<endl;
	}
}

C++: # include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;


int main() {
  int n;

  while (cin >> n && n) {
    vector<int> scr(n);
    for (int i=0; i<n; i++) {
      cin >> scr[i];
    }

    int  sum = 0;
    int _max = scr[0];
    int _min = scr[0];

    for (int s : scr) {
      sum  += s;
      _min = min(_min, s);
      _max = max(_max, s);
    }

    sum -= _max;
    sum -= _min;

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

  return 0;
}