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>
#include <cstdio>
using namespace std;

int main() {
    int scores[1000];
    int n;
    int min, max;
    int sum = 0;
    int minf = 0, maxf = 0;

    while(cin >> n) {
        if(n == 0) {
            break;
        }
        for(int i = 0; i < n; i++) {
            scanf("%d", &scores[i]);
            if(i == 0) {
                min = max = scores[i];
            }
            if(scores[i] < min) {
                min = scores[i];
            } else if(scores[i] > max) {
                max = scores[i];
            }
        }

        minf = 0;
        maxf = 0;
        sum = 0;
        for(int i = 0; i < n; i++) {
            if(!minf && scores[i] == min) {
                minf = 1;
            } else if(!maxf && scores[i] == max) {
                maxf = 1;
            } else {
                sum += scores[i];
            }
        }
        cout << sum / (n - 2) << endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,i=0,ans=0,mx=-1,mn=99999999,p;
    while(1){
        cin>>p;
        if(p==0) break;
        for(i=0;i<p;i++){
            cin>>n;
            mx=max(mx,n);
            mn=min(mn,n);
            ans+=n;
        }
        cout<<(ans-mx-mn)/(i-2)<<endl;
        ans=0,mx=-1,mn=99999999;
    }
    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 tensu[200];
  int max = 0;
  int min = 1000;
  int sum=0;
  while(cin>>n,n){
	REP(i,n){
	  cin >> tensu[n];
	  sum+=tensu[n];
	  if(max<tensu[n])
		max=tensu[n];
	  if(min>tensu[n])
		min=tensu[n];
	}

	//cout<<min<<endl<<max<<endl<<sum<<endl;//


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

  }

  return 0;
}

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

int main(){
  int N;
  while(cin >> N && N>0){
    int pt,total,max,min;
    total=0;
    max=0;
    min=1000;

    for(int i=0;i<N;i++){
      cin >> pt;
      if(pt>max) max=pt;
      if(pt<min) min=pt;
      total+=pt;
    }
    cout << (total-min-max)/(N-2) << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
   int n1;
int main(){
	while (true){
		cin >> n1;
		int a[n1]; if (n1 <= 0) break;
		for (int i = 0; i < n1; i++){
			cin >> a[i];
		}
		sort(a, a + n1);
		a[0] = { 0 };
		a[n1 - 1] = { 0 };
		for (int i2 = 1; i2 < n1; i2++){
			a[0] += a[i2];
		}
		cout << a[0] / (n1 - 2) << endl;
	}
		return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<random>
#include<string>
typedef long long ll;
using namespace std;
int main(){
  ll N;
  ll s[1100];
  ll sum=0;
  ll t=0;
  while(t<=20){
  t++;
  cin >> N;
  for(ll i = 0; i < N; ++i){
      cin >> s[i];
  }
  sort(s,s+N);
  for(ll i = 1; i < N-1; ++i){
    sum+=s[i];
  }
  cout<<sum/(N-2)<<endl;
}
}

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

typedef vector <int> VI;

int main( void )
{
    int n, s;
    while ( cin >> n && n )
    {
        VI v(n);
        for ( int i = 0; i < n; i++ )
        {
            cin >> v[i];
        }
        sort( v.begin(), v.end() );
        
        double sum = 0.0;
        for ( int i = 1; i + 1 < n; i++ )
        {
            sum += v[i];
        }

        int score = (int)floor( sum / ( n - 2 ) );
        cout << score << endl;
    }

    return 0;
}

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

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

int main() {
 while(true) {
  int n;
  scanf("%d", &n);
  if (!n) break;
  int m=0x7fffffff;
  int M=-0x7fffffff;
  int sum=0;
  rep(i, n) {
   int t;
   scanf("%d",&t);
   sum+=t;
   if(m>t)m=t;
   if(M<t)M=t;
  }
  sum-=m;
  sum-=M;
  printf("%d\n",sum/(n-2));
 }
}

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

int main(){
	/*
	int A[100];
	for (int i = 0; i <= 99; i++){
		A[i] = 99-i;
	}
	sort(A,A+100);
	for (int i = 0; i <= 99; i++){
		cout << A[i] << endl;
	}
	*/

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

}

C++: #include<iostream>
#include<algorithm>
using namespace std;
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 <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  while (cin >> n && n) {
    vector<int> score(n);
    rep(i, n)
      cin >> score[i];
    sort(score.begin(), score.end());
    int ans = 0;
    for (int i = 1; i+1 < n; i++)
      ans += score[i];
    ans /= n-2;
    cout << ans << '\n';
  }
  return 0;
}