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>

using namespace std;

int main () {

  while (true){

    int n;
    int i;
    int s = 0;
    int mi = 0;
    int ma = 0;
    cin >> n;

    if (n == 0)
      break;
??????
??????int p[100];

    for (i=0,i<n,i++){
      cin >> p[i];

      if (p[i] < mi)
        mi << p[i];

      if (p[i] > ma)
        ma << p[i];

      s += p[i];

    }

    cout << (s - mi - ma) / (n-2)

  }

  return 0;

}

C++: #include "bits/stdc++.h"
using namespace std;
#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
typedef long long ll;

const int INF = 1e9 + 7;
const long long LLINF = 1e18;

ll n;
int main() {
    while(cin>>n, n!=0){
        ll s;
        ll mx=-LLINF, mn=LLINF, sum=0;
        REP(i, 0, n){
            cin>>s;
            mx=max(mx, s);
            mn=min(mn, s);
            sum+=s;
        }

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

C++: #include <iostream>

using namespace std;

int main(){
	int max,min,sum,ans,n;
	int s[101];

	while(1){
		//ÏÌú»
		max = 0;
		min = 1001;
		sum = 0;
		
		//f[^ZbgnÌüÍ
		cin >> n;
		if(n==0) break;//0 0ªüÍ³ê½çI¹

		//f[^ZbgÌ¾¯_ðüÍ
		for(int i=0 ; i<n ; i++){
			cin >> s[i];
		}
		//ÅålAÅ¬lÌlðÛ·é
		for(int i=0 ; i<n ; i++){
			if(max<s[i]) max = s[i];
			if(min>s[i]) min = s[i];
		}
		//ÅåÌ_ðÐÆÂr·é(0ðüêé)
		for(int i=0 ; i<n ; i++){
			if(max==s[i]){
				s[i]=0;
				break;
			}
		}
		//Å¬Ì_ðÐÆÂr·é(0ðüêé)
		for(int i=0 ; i<n ; i++){
			if(min==s[i]){
				s[i]=0;
				break;
			}
		}
		//_Ìvðßé
		for(int i=0 ; i<n ; i++){
			sum += s[i];
		}
		//_Ìv©ç½Ïðßé
		ans = sum/(n-2);
		//¦ÌoÍ
		cout << ans << endl;
	}

	return 0;
}

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

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

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

using namespace std;

int main(){
    vector<int> vc;
    int n;
    while(cin >> n){
        if(n == 0) break;
        int tmp;
        vc.clear();
        REP(i,n){
            cin >> tmp;
            vc.push_back(tmp);
        }
        sort(vc.begin(), vc.end());
        vc.erase(vc.begin());
        vc.erase(--vc.end());
        int sum = 0;
        vector<int>::iterator it = vc.begin();
        while(it != vc.end()){
            sum += (*it);
            it++;
        }
        cout << sum/(n-2) << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

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

C++: #include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;

int main(){
	int n;
	while(scanf("%d",&n),n){
		vector < int > vi;
		for(int i = 0; i < n; i++){
			int tmp;
			scanf("%d",&tmp);
			vi.push_back(tmp);
		}
		sort(vi.begin(),vi.end());
		double ave = 0.0;
		for(int i = 1; i < n-1 ;i++){
			ave += vi[i];
		}
		printf("%.0lf\n",floor(ave/(n-2)));
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>

#define ll long long int
#define MOD 1000000007
#define pb push_back
#define ub upper_bound
#define lb lower_bound

using namespace std;

int main(){
    int N;
    int s[101];
    while(1){
        cin >> N;
        if(N==0){
            break;
        }
        for(int i=0;i<N;i++){
            cin >> s[i];
        }
        int ans=0;
        int MAX=s[0],min=s[0];
        for(int i=0;i<N;i++){
            if(MAX<s[i]){
                MAX=s[i];
            }
            if(min>s[i]){
                min=s[i];
            }
        }
        for(int i=0;i<N;i++){
            ans+=s[i];
        }
        ans-=MAX;
        ans-=min;
        cout << ans/(N-2) << endl;
    }
    return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>

int qtmp(const void *a,const void *b){
    return *(int*)a - *(int*)b;
}

int main(void){
    int i,n;

    int ascore[20] = {};
    int count=0;

    while(1){
    scanf("%d",&n);
    if(n == 0) break;

    int score[n];

    for(i=0;i<n;i++){
        scanf("%d",&score[i]);
    }

    for(i=0;i<n;i++){
        qsort(score,n,sizeof(int),qtmp);
    }

    double dave=0;
    int iave=0;

    for(i=1;i<n-1;i++){
        dave += score[i];
    }

    iave = (int)((dave / (n-2)) + 0.5);

    ascore[count] = iave;
    count++;

    }

    for(i=0;i<20;i++){
        if(ascore[i] == 0) break;
        printf("%d\n",ascore[i]);
    }

    return 0;
}

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

int main()
{
    int N, S, ans, vmax, vmin, sum, x, y;
    while(true){
        cin >> N;
        if (N == 0) break;
        cin >> x >> y;
        vmin = min(x,y);
        vmax = max(x,y);
        sum = x + y;
        
        for (int i=0; i< N - 2;i++){
            cin>>S;
            vmin = min(vmin, S);
            vmax = max(vmax, S);
            sum+=S;
        }
        sum -= (vmin+vmax);
        cout << sum / (N-2)<<endl;
    }
}

C++: #include <iostream>

using namespace std;

int main(){
	while (cin >> n && n > 0){
		int large = 0;
		int small = 1000;
		int sum = 0;
                int n, s ;
  		for (int i=0; i>n; ++i){
			cin >> s;
			sum = sum + s;
			if (large < s) {large = s};
			if (small > s) {small = s};
		}
		int ans = 0;
		ans = (sum - large - small) / (n - 2);
		cout << ans << endl ;
	}
}