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())
		if n == 0 {
			break
		}
		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 < len(scores)-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

C++: #include <stdio.h>
int main(){
  int a,max,min,s,sum,i;
  while(1){
    scanf("%d",&a);
    if(a==0)break;
    max=-1;
    min=1001;
    sum=0;
    for(i=0;i<a;i++){
      scanf("%d",&s);
      sum+=s;
      if(max<s)max=s;
      if(min>s)min=s;
    }
    sum-=max;
    sum-=min;
    sum=sum/(a-2);
    printf("%d\n",sum);
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int N, S;
int main() {
	while (cin >> N && N > 0) {
		int sum = 0;
		int largest = 0;
		int smallest = 1000;
		for (int i = 0; i < N; ++i) {
			cin >> S;
			if (largest < S) {
				largest = S;
			} else if (smallest > S) {
				smallest = S;
			}
			sum += S;
		}
		cout << ((sum - largest - smallest) / (N - 2)) << endl;
	}
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>

#pragma warning( disable: 4996 )

using namespace std;

typedef long long ll;

#define INF 100000000
#define EPS 1e-9

#define MAX_N 100

int n;
vector<int> ans_list;

int main(){
	
	while (true){
	
		cin >> n;
		if (n == 0)
			break;

		vector<int> score;

		for (int i = 0; i < n; i++){
			int s;
			cin >> s;
			score.push_back(s);
		}
	
		sort(score.begin(), score.end());

		int ans = 0;

		for (int i = 1; i < score.size() - 1; i++){
			ans += score[i];
		}

		ans_list.push_back(ans / (score.size() - 2));
	
	}

	for (int i = 0; i < ans_list.size(); i++){
		cout << ans_list[i] << endl;
	}

	return 0;

}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int getAverageScore(int N, VI S){
	int min = S[0];
	int max = S[0];
	int sum = 0;
	FOR(i, 1, N){
		sum += S[i];
		if (min > S[i]){ min = S[i]; }
		if (max < S[i]){ max = S[i]; }
	}
	sum -= (min + max);
	return sum / N;
}
int main(){
	int N;
	VI S;
	while (true){
		cin >> N;
		if (N == 0){ break; }
		REP(i, N){
			cin >> S[i];
		}
		cout << getAverageScore(N, S)<<endl;
	}
	return 0;
}

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

using namespace std;

int main() {
	
	int n;
	
	while(cin >> n && n!=0) {
		
		int *A;
		int sum = 0;
		
		A = new int[n];
		
		for(int i=0;i<n;i++)
			cin >> A[i];
		
		sort(A, A+n);
		
		for(int i=1;i<n-1;i++)
			sum += A[i];
		
		cout << sum / (n - 2) << "\n";
		delete [] A;
		A = NULL;
	}

	return 0;
}

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

using namespace std;
int main(){
    int n=1;
    while (true){
        cin >> n;
        if(n==0) break;
        vector<int> a(n);
        for (int i = 0 ;i<n;i++){
            cin >> a[i];
         }
        sort(a.begin(),a.end());
        int sum=0;
        for (int i=1;i<n-1;i++){
            sum+=a[i];
        }
        cout << sum /(n-2)<<endl;
    }
}

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

int main()
{
	while (true) {
		int n;

		cin >> n;

		if (n == 0) {
			break;
		}

		int minx = 1000;
		int maxx = 0;
		int temp;
		int sum = 0;
		int avr;

		for (int i = 0; i < n; i++) {
			cin >> temp;

			sum += temp;

			minx = min(minx, temp);
			maxx = max(maxx, temp);
		}

		if (minx == maxx) {
			sum -= minx;
			avr = sum / (n - 1);
		}
		else {
			sum -= minx;
			sum -= maxx;
			avr = sum / (n - 2);
		}

		cout << avr << endl;
	}

	return 0;
}

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

int main() {
    int count;
    while (cin >> count && count > 0) {
        int cur;
        int sum = 0;
        int maxScore = 0;
        int minScore = 1001;
        for (int i = 0; i < count; i++) {
            cin >> cur;
            sum += cur;
            maxScore = max(maxScore, cur);
            minScore = min(minScore, cur);
        }
        cout << (sum - minScore - maxScore) / (count - 2) << endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    while(N){
        int sum = 0,a;
        rep(i,0,N){
            cin >> a;
            sum += a;
        }
        cout << sum / N << endl;
        cin >> N;
    }
}