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 N, A[1024],Max,Min,Sum;

int main(){
 while(cin >> N && N>0){
  for (int i=0; i<N; ++i)
    cin >> A[i];
  for (int j=0; j<(N-1); ++j){
    Max=A[0];
	if(A[j+1]>A[j]) Max=A[j+1];
    }
  for (int k=0; k<(N-1); ++k){
    Min=A[0];
	if(A[k+1]<A[k]) Min=A[k+1];
	}
  for (int l=0; l<N; ++l){
    Sum += A[l];
	}
  cout<< (Sum-Max-Min)/(N-2) << endl;
 }
}

C++: # include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;


int main() {
  int n;

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

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

    int  sum = 0;
    int _max = scr[0];
    int _min = scr[0];

    for (int s : scr) {
      sum  += s;
      _min = min(_min, s);
      _max = max(_max, s);
    }

    sum -= _max;
    sum -= _min;

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

C++: #include<stdio.h>
int main(){
  int a,b,c,d,i,j=0,dt[1000],ls[1000],max,min,l,sum;
  while(1){
    scanf("%d",&a);
    if(a==0)break;
    sum=0;
    max=0;
    min=10000;
    for(i=0;i<a;i++){
      scanf("%d",&b);
      dt[i]=b;
    }
    for(i=0;i<a;i++){
      if(dt[i] > max) max=dt[i];
      if(dt[i] < min) min=dt[i]; 
    } 
    for(i=0;i<a;i++){
      if(dt[i]==max) 
	max=0;
      else if(dt[i]==min)
	min=0;
      else sum+=dt[i];
    }
    ls[j]=sum/(a-2);
    j++;
  }
  for(l=0;l<j;l++)
    printf("%d\n",ls[l]);
  return 0;
}

C++: #include <iostream>

using namespace std;


int main(void) {
    int n;
    int score, sum_score;
    int max_score, min_score;
    int i;

    cin >> n;
    while (n) {
        sum_score = 0;
        max_score = 0;
        min_score = 1000;
        for (i=0; i<n; i++) {
            cin >> score;
            sum_score += score;
            if (score < min_score) {
                min_score = score;
            }
            if (score > max_score) {
                max_score = score;
            }
        }

        sum_score -= min_score + max_score;
        cout << sum_score / (n-2) << endl;

        cin >> n;
    }

    return 0;
}

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

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

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

int main(void)	{
	while (true)	{
		int umpire, temp, summ, mini, maxi;
		mini = 1000;
		maxi = 0;
		summ = 0;
	
		scanf("%d", &umpire);
		if (umpire == 0)	{
			break;
		}
		for (int i = 0; i <= umpire - 1; i++)	{
			scanf("%d", &temp);
			mini = std::min(mini, temp);
			maxi = std::max(maxi, temp);
			summ = summ + temp;
		}
		printf("%d\n", (summ - mini - maxi) / (umpire - 2));
	}
	return 0;	
}

C++: #include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int inf = 1000000000;
const int mod = 1000000007;
const double EPS = 1e-9;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

int n;
int s[100];

int main() {
	// cin.tie(0); // tie
	// ios::sync_with_stdio(false); // sync
	while (cin >> n, n) {
		int mini = 10000, maxi = -1;
		int sum = 0;
		rep(i, n) {
			int s; cin >> s;
			if (mini > s) mini = s;
			if (maxi < s) maxi = s;
			sum += s;
		}
		int av = (sum - mini - maxi) / (n - 2);
		cout << av << endl;
	}
	return 0;
}

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

int main()
{
	int n;
	for (; cin >> n, n != 0;)
	{
		int sum = 0;
		int max = -1;
		int min = 1001;
		int s[100];
		for (int i = 0; i < n; i++)
		{
			cin >> s[i];
			max = (max < s[i]) ? s[i] : max;
			min = (min > s[i]) ? s[i] : min;
			sum += s[i];
		}
		cout << (sum - (max + min)) / (n - 2) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main(){
  int n;
  while(1){
    cin >> n;
    if(n==0)break;
    vector<int> p(n);
    int sum=0;
    rep(i,n){
      cin >> p[i];
      sum += p[i];
    }
    int min,max;
    min=*min_element(p.begin(),p.end());
    max=*max_element(p.begin(),p.end());
    sum -= (max+min);
    int avg = sum / (n-2);
    cout << avg << endl;
  }
  return 0;
}

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

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main() {
    int N,input;
    while (1){
        scanf("%d", &N);
        if (N==0){
            break;
        }
        int sum=0,max=0,min=1001;
        for (int i;i<N;i++) {
            cin >> input;
            sum = sum+input;
            if (max < input) max = input;
            if (min > input) min = input;
        }
        printf("%d\n", (sum-max-min)/(N-2));
    }
}