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<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];
		i=maxnum;
		}
		if(score[i] < minscore){
		minscore = score[i];
		i = minnum;
		}
	}
score[maxnum] = 0;
score[minnum] = 0;
int lastscore = 0;
for(int j=0;j<judge;j++){
lastscore += score[j];
}
lastscore = lastscore/(judge - 2);
cout << lastscore <<endl;
return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n,s,m,M,ans;
	while(true){
		cin>>n;
		if(n==0){
			return 0;
		}
		m = 1005;
		M= -1;
		ans=0;
		for(int i=0;i<n;i++){
			cin>>s;
			m=min(m,s);
			M=max(M,s);
			ans+=s;
		}
		n-=2;
		ans=ans-M-m;
		ans /= n;
		cout<<ans<<endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int p;
  int s[1000];
  int sum=0;
  while(1){
    cin>>p;
    if(p==0) break;
    for(int i=0;i<p;i++){
      cin>>s[i];
      sum+=s[i];
    }
    sort(s,s+p);
    for(int j=0;j<p;j++){
      cout<<s[j]<<endl;
    }
    /*cout<<sum-s[0]-s[p-1]<<endl;*/
  }
  return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

int n;
int d;

int main()
{
  while(cin >> n, n){
    int sum = 0;
    int mn = INF;
    int mx = -INF;
    rep(i, n){
      cin >> d;
      sum += d;
      minup(mn, d);
      maxup(mx, d);
    }

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

  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	int n;
	int mmax = -1;
	int mmin = 10000;
	int tmp;
	ll int sum;
	while(cin >> n,n){
		mmax = -1;
		mmin = 10000;
		sum = 0;
		REP(i,n){
			cin >> tmp;
			mmax = max(tmp,mmax);
			mmin = min(tmp,mmin);
			sum += tmp;
		}
		cout << (int)((sum-mmax-mmin)/(n-2)) << endl;
	}
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
using namespace std;
int main() {
	int n;
	vector<long long>li;
	while (cin >> n) {
		if (n == 0)break;
		vector<long long>l;
		long long a;
		for (int i = 0; i < n; i++){
			cin >> a;
			l.push_back(a);
		}
		sort(l.begin(), l.end());
		long long sum = 0;
		int g = l.size();
		for (int i = 1; i < g - 1; i++){
			sum += l[i];
		}
		li.push_back(sum / (g - 2));
	}
	for (long long i : li) {
		cout << i << endl;
	}
	char c;
	cin >> c;
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n,s;
    while (1) {
        cin >> n;
        if(n==0) break;
        int p = n;
        vector<int> score;
        cin >> s;
        n--;
        score.push_back(s);
        int mins=s,maxs=s,result=0;
        while(n--){
            cin >> s;
            maxs = max(maxs,s);
            mins = min(mins,s);
            score.push_back(s);
        }
        vector<int>::iterator it;
        it = score.begin();
        while(it != score.end()){
            bool maxf=false,minf=false;
            if (((*it)==mins) && (minf == false)) {
                minf = true;
            }
            else if(((*it)==maxs) && (maxf == false)){
                maxf = true;
            }
            else{
                result += (*it);
            }
            it++;
        }
        cout << result/(p-2) << endl;
    }
}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	int n;
	while(n=read()){
		int score[n];
		int mean=0;
		REP(i,n){
			score[i] = read();
		}
		
		sort(score,score+n);

		
		FOR(i,1,n-1){
			mean += score[i];
		}
		mean /= (n-2);
		cout << mean << endl;
	}
}

C++: #include <cstdio>
#include <iostream>

int main()
{
	int n, a, b;
	while(1){
		std::cin >> n;
		if(n == 0) break;
		int max = -1, min = 1001, sum = 0;
		for(int i = 0; i < n; i++){
			std::cin >> a;
			if(a > max) max = a;
			if(a < min) min = a;
			sum += a;
		}
		b = (sum - max - min) / (n - 2);
		std::cout << b << std::endl;
	}
	return 0;
}

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

vector<int> v;

int main(){
    int n;
    while(1){
        cin >> n;
        if(n == 0)break;
        for(int i=0; i < n; i++){
            int tmp; cin >> tmp;
            v.push_back(tmp);
        }
        int sum = 0;
        sort(v.begin(), v.end());
        for(int i=1; i < n-1; i++){
            sum += v[i];
        }
        cout  << sum / (n - 2) << endl;
        v.clear();
    }

    return 0;
}

C++: #include <iostream>

using namespace std;

int main(void) {
	int n[20], s[20][100], sum[20], shift;
	int j = 0;
	while (1) {
		sum[j] = 0;
		cin >> n[j];
		if (n[j] == 0)
			break;

		for (int i = 0; i < n[j]; i++) {
			cin >> s[j][i];
		}

		// 昇順ソート
		for (int i = 0; i < n[j]; i++) {
			for (int t = i + 1; t < n[j]; t++) {
				if (s[j][i] > s[j][t]) {
					shift = s[j][i];
					s[j][i] = s[j][t];
					s[j][t] = shift;
				}
			}
		}
		for (int i = 1; i < n[j] - 1; i++) {
			sum[j] += s[j][i];
		}
		sum[j] = sum[j] / (n[j] - 2);
		cout <<  sum[j] << endl;
		j++;

	}
	return 0;
}