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 main(){
  int n;
  while(1){
    cin >> n;
    if(n == 0)
      break;
    int x[n];
    for(int i=0;i<n;i++){
      cin >> x[i];
    }

    //sort
    int t;
    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
        if(x[i]<x[j]){
          t = x[i];
          x[i] = x[j];
          x[j] = t;
        }
      }
    }

    //calc
    int sum=0;
    for(int i=1;i<n-1;i++){
      sum+=x[i];
    }
    cout << sum/(n-2) << "\n";
  }
  return 0;
}

C++: #include <iostream>
#include <cmath>
#include <utility>
#include <functional>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

int main() {
	int n;
	cin >> n;

	while (n != 0) {
		vector<int> point(n);
		for (int i = 0; i < n; i++) cin >> point[i];

		sort(point.begin(), point.end());
		int sum = 0;
		for (int i = 1; i < n - 1; i++) sum += point[i];

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

		cin >> n;
	}

	return 0;
}

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

int main(){

  int n, s;

  while(cin >> n, n){
    int sum = 0;
    int max_s = -1, min_s = 10001;
    for(int i = 0; i < n; i++){
      cin >> s;
      min_s = min(min_s, s);
      max_s = max(max_s, s);
      sum += s;
    }
    sum = sum - max_s - min_s;
    sum /= (n - 2);
    cout << sum << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <stdlib.h>
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;
      sum += S;
      if (largest < S)
	largest=S;
      if (smallest > S)
	smallest=S;
    }
    int average = 0;
    average = (sum - largest - smallest) / (N - 2);
    cout << "Average:";
    cout << average << endl;
  }
}

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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

#define int ll

main()
{
  while(1){
    int n; cin >> n;
    if(n == 0) break;
    int sum = 0, minv = inf, maxv = 0;
    int s;
    rep(i,n){
      cin >> s;
      sum += s;
      minv = min(minv,s);
      maxv = max(maxv,s);
    }
    cout << (sum - minv - maxv) / (n - 2) << endl;
  }
}

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

int main()
{
    int a,b[100];
    int max=0,min=100,sum=0,result;
    for(int i=0;i<a;i++){
        cin>>b[i];
        sum+=b[i];
        if(b[i]<min){
            min=b[i];
        }
        else if(b[i]>max){
            max=b[i];
        }
    }
    result=sum-min-max;
    cout<<result;
    return 0;
}

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

int main(){
  int i,n,sum = 0;
  int pt[1000];
  while(cin>>n,n){
    sum = 0;
    for(i = 0;i<n;i++) cin>>pt[i];
    sort(pt,pt + n);
    for(i = 1;i<n-1;i++){
      //cout<<pt[i]<<endl;
      sum += pt[i];
    }
    int tmp = sum/(n-2);
    cout<<sum/(n-2)<<endl;
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

int main() {
    int n, min, max, sum, p;
    while (true) {
        cin >> n;
        if (n == 0) {
            break;
        }
        sum = 0;
        for (int i=0; i<n; i++) {
            cin >> p;
            sum += p;
            if (i == 0) {
                min = p;
                max = p;
            }
            min = p<min? p: min;
            max = p>max? p: max;
        }
        cout << (sum-min-max)/(n-2) << endl;
    }
    return 0;
}

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

int main(){
  int N;
  
  while(cin>>N){
    if(N==0){
      break;
    }
    int max=0,min=1001,sum=0,a;
    for(int i=0;i<N;i++){
      cin >>a;
      if(max<a){ max=a; }
      if(min>a){ min=a; }
      sum+=a;
  }
    sum-=max;
    sum-=min;
    int ave = sum/(N-2);
    cout << ave <<endl;
  }

  return 0;
}

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

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

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

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

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

        int max=0,min=1000;;

        for(int i=0;i<n;i++){
            if(s[i]>max)max=s[i];
            else if(s[i]<min)min=s[i];
        }
        
        int sum=0;
        for(int i=0;i<n;i++){
            sum +=s [i];
        }


        sum -=max;
        sum -=min;

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

    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

int main(){
  ll N;
  cin>>N;
  ll T[N];
  ll sum=0;
  for(ll i=0; i<N; ++i){
    cin>>T[i];
    sum+=T[i];
  }
  cout<<sum/N<<endl;
  
}

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

int main(void) {
	for (;;) {
		int n;
		cin >> n;
		if (n == 0)
			break;

		int s[100];
		int max = 0, min = 1000;
		for (int i = 0; i < n; i++) {
			cin >> s[i];
			if (max < s[i]) {
				max = s[i];
			}
			if (min > s[i]) {
				min = s[i];
			}
		}

		bool flag_max = true;
		bool flag_min = true;
		int total = 0;
		for (int i = 0; i < n; i++) {
			if ((s[i] == max) && flag_max) {
				flag_max = false;
				continue;
			} else if ((s[i] == min) && flag_min) {
				flag_min = false;
				continue;
			} else {
				total += s[i];
			}
		}
		int ave = total / (n - 2);
		printf("%d\n", ave);
	}
	return 0;
}