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<iostream>
#include<algorithm>
int MIN,MAX,n,sum,a;
int main(){
while(true){
cin>>n;if(!n){break;}
MIN=10000000;
MAX=0;sum=0;
for(i=0;i<n;i++){cin>>a;MIN=min(MIN,a);MAX=max(MAX,a);sum+=a;}
cout<<sum-MIN-MAX<<endl;
}
}

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

int main(){
    int n;
    while(cin >> n, n){
        int sum = 0, mi = 1000, ma = 0, x;
        for(int i = 0; i < n; i++){
            cin >> x;
            sum += x;
            mi = min(mi, x);
            ma = max(ma, x);
        }
        cout << (sum-mi-ma)/(n-2) << endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	while(true){
		int n,sum=0,mx=-1,mn=100000;
		cin >> n;
		if(n==0) break;
		for(int i=0;i<n;i++){
			int s;
			cin >> s;
			mn=min(mn,s);
			mx=max(mx,s);
			sum+=s;
		}
		cout << (sum-mn-mx)/(n-2) << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	int x[1000];
	int y[20];
	int max;
	int min;
	n = 1;
		int j = 0;
		while (n != 0){
			
			cin >> n;
			max = 0;
			min = 1000;
				y[j] = 0;
			for (int i = 0; i < n; i++){
				cin >> x[i];
				if (max < x[i]) max = x[i];
				if (min > x[i]) min = x[i];
				y[j] += x[i];
			}
			y[j] -= max + min;
			y[j] = y[j] / (n - 2);
			j++;
		}
	for (int k = 0; k < j; k++){
		cout << y[j]<< endl ;
	}
	return 0;
}

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

int main() {
    int score[100];
    int i,j;
    int n;
    int tmp;
    int sum;
    int scorel;
    
    while(1){
        sum = 0;
        cin >> n;
        if(n == 0){
            break;
        }
        
        for(i = 0;i < n;i++){
            cin >> score[i];
        }
        
        for(i = 0;i < n - 1;i++){
            for(j = i + 1;j < n;j++){
                if(score[i] > score[j]){
                    tmp = score[i];
                    score[i] = score[j];
                    score[j] = tmp;
                }
            }
        }
        
        for(i = 1;i < n - 1;i++){
            sum = sum + score[i];
        }
        
        scorel = sum / (n - 2);
        
        cout << scorel << endl;
        
    }
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define vsort(v) sort(v.begin(),v.end())
#define asort(a,n) sort(a, a + n)
#define vi vector<int>
#define vd vector<double>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int N;
    int ans;
    int cnt;
    vi vec(20);
    while(true){
        vec.assign(20, -1);
        ans = 0;
        cnt = 0;
        cin >> N;
        if(N == 0) return 0;
        rep(i, N){
            cin >> vec[i];
        }
        vsort(vec);
        REP(i, 21 - N, 19){
            ans += vec[i];
            cnt++;
        }
        cout << (int)(ans / cnt) << endl;
    }


    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main() {
  int n;
  while(cin >> n && n) {
	vector<int> v(n, 0);
	for(int i = 0; i < n; ++i) {
	  cin >> v[i];
	}
	*min_element(v.begin(), v.begin() + n) = 0;
	*max_element(v.begin(), v.begin() + n) = 0;
	
	cout << accumulate(&v[0], &v[n], 0) / (n - 2) << endl;
  }

  return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





int main() {
    int n;
    cin >> n;
    
    while(n){
        double mn = 1e9, mx = 0, sum = 0;
        REP(i, n){
            double t;
            cin >> t;
            sum += t;
            mx = max(mx, t);
            mn = min(mn, t);
        }
        cout << (int)((sum - mx - mn) / (n - 2)) << '\n';
        
        cin >> n;
    }
}

C++: #include <stdio.h>

struct data {int score[100],n;} table[20];
struct data *d;

void sort(int *a,int n){
  int i,j,t;
  for(i=0; i<n-1; i++) for(j=n-1; j>i; j--)
  if(a[j-1]>a[j]) {t=a[j-1]; a[j-1]=a[j]; a[j]=t;}
}

int main(){
  int i,j,N,ave;
  for(i=0;; i++) {d=&table[i];
    scanf("%d",&d->n );
    if(d->n==0) break;
    for(j=0; j<d->n; j++) scanf("%d",&d->score[j] ); }
    N=i;
    for(i=0; i<N; i++) {d=&table[i];ave=0;
      sort(d->score,d->n);
      for(j=1; j<d->n-1; j++) ave+=d->score[j];
      ave/=d->n-2;
      printf("%d\n",ave);}
    }

C++: #include <bits/stdc++.h>
using namespace std;
int n;
long int ans;
int main() {
  for(;;) {
    scanf("%d", &n);
    if(n == 0) break;
    vector<int> v(n);
    for(int i = 0; i < n; ++i) scanf("%d", &v[i]);
    sort(begin(v), end(v));
    v[n - 1] = 0, v[0] = 0;
    for(int i = 0; i < n; ++i) ans+=v[i];
    ans /= n - 2;
    printf("%ld\n", ans);
    n = 0, ans = 0;
    v.clear();
  }
  return 0;
}

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

template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, T b) { if(b < a) a = b; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	for(int n; cin >> n, n;) {
		int sum = 0, mx = 0, mn = INT_MAX;
		for(int i = 0; i < n; ++i) {
			int score;
			cin >> score;
			sum += score;
			chmax(mx, score);
			chmin(mn, score);
		}

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

	return EXIT_SUCCESS;
}

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

int main(void){
    int n,s,sum=0,i=0;
    int ma=0;
    int mi=10000;
    while(true){
        cin>>n;
        sum=0;
        i=0;
        ma=0;
        mi=10000;
        if(n==0)break;
        //cout<<n<<endl;
        while(i<n){
            cin>>s;
            ma=max(ma,s);
            mi=min(mi,s);
            sum+=s;
            i++;
        }
        sum=sum-ma-mi;
        cout<<sum/(n-2)<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <complex>
using namespace std;

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


int main()
{
        int n;
        while (cin >> n, n) {
                vector<int> vs = vector<int>(n);
                rep(i, n) cin >> vs[i];
                sort(vs.begin(), vs.end());
                int ans = 0;
                REP(i, 1, n-1)
                        ans += vs[i];
                ans /= n-2;
                cout << ans << endl;
        }
        return 0;
}