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>
#include <algorithm>
#include <array>
#include <numeric>

using namespace std;

int main() {
  array<int,100> s;
  int n;
  while ((cin >> n) && n != 0) {
    for (int i=0; i<n; i++) cin >> s[i];
    int ssum = accumulate(s.begin(), s.begin()+n, 0);
    int smax = *max_element(s.begin(), s.begin()+n);
    int smin = *min_element(s.begin(), s.begin()+n);
    cout << (ssum-smax-smin)/(n-2) << endl;
  }
  return 0;
}

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

int main() {
	int i, n, tmp, sum;
	priority_queue<int> q;

	while (1) {
		cin >> n;
		if (n == 0)break;
		sum = 0;
		for (i = 0; i < n; i++) {
			cin >> tmp;
			q.push(tmp);
		}
		q.pop();
		while (q.size() > 1) {
			sum += q.top();
			q.pop();
		}
		q.pop();
		cout << sum / (n - 2) << endl;
	}

	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];
		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;
}