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 <bits/stdc++.h>
using Int = int64_t;

int main() {
   for(;;) {
      Int n;
      std::cin >> n;
      if( n == 0 ) break;
      std::vector<Int> xs(n);
      for(Int i = 0; i < n; ++i) {
         std::cin >> xs[i];
      }
      std::sort(xs.begin(), xs.end());
      Int total = 0;
      for(Int i = 1; i < (Int)xs.size()-1; ++i) {
         total += xs[i];
      }
      Int res = total / (n-2);
      std::cout << res << std::endl;
   }
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <numeric>
#include <cstring>
#include <cmath>
#include <set>
#include <climits>
#include <queue>
#include <stack>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using edge = struct
{
    int to;
    int cost;
};

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    int n;

    while (cin >> n, n)
    {
        int s = 0;
        int maxs = 0, mins = iINF, sum = 0;

        rep(i, n)
        {
            cin >> s;
            maxs = max(maxs, s);
            mins = min(mins, s);
            sum += s;
        }

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

    return 0;
}

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

using namespace std;

int main(){
  int n;
  while(cin>>n){
    if(n==0)break;
    vector<int> score(n);
    for(int i=0;i<n;i++)cin>>score[i];

    vector<int>::iterator minIt = min_element(score.begin(),score.end());
    int minIndex = distance(score.begin(),minIt);
    score.erase(score.begin()+minIndex-1);

    vector<int>::iterator maxIt = max_element(score.begin(),score.end());
    int maxIndex = distance(score.begin(),maxIt);
    score.erase(score.begin()+maxIndex-1);

    int sum = accumulate(score.begin(),score.end(),0);
    cout << sum/score.size() << endl;
  }
  return 0;
}

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

using namespace std;

int main()
{
  int n, a[21], t;

  while(cin>>n && n){
    for(int i = 0; i < n; i++){
      cin >> a[i];
    }
    sort(a, a+n);
    t = 0;
    for(int i = 1; i < n-1; i++){
      t += a[i];
    }

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

  return 0;
}

C++: #include <iostream>

using namespace std;

int main() {

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

        int sum = 0, min_ = 1001, max_ = -1;
        for (int i = 0; i < n; i++) {
            int s;
            cin >> s;
            sum += s;
            min_ = min(min_, s);
            max_ = max(max_, s);
        }

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

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

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

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

C++: #include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
int flag = 1;

int main(){
    cin >> flag;
    while(flag){
        int temp = 0, score = 0;
        int M = 0, m = 1000;
        REP(i,flag){
            cin >> temp;
            score += temp;
            M = max(temp,M);
            m = min(temp,m);
        }
        cout << (score-M-m)/(flag-2) << endl;
        cin >> flag;
    }
    return 0;
}

C++: 
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <iomanip>
#include <functional>
using namespace std;
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

int main(int argc, char* argv[])
{
			int ninzu=0;
	while(cin >> ninzu){
		int ans=0;
		int i=0;
		int temp=0;
		int a=0;

		vector <int>  s;

		
		for(i=0;i<ninzu;i++){
			cin >> a;
			if(temp < a){
				temp = a;
			}
			s.push_back(a);
			if(a == 0)break;
		}
		sort( ALL(s) );

		for(i=1;i<s.size()-1;i++){
			if(s[i] != temp || s[i] != 0)ans+= s[i];
		}

		ans = ans / (i-1);

		cout << ans << endl;
		ans=0;
	}

    return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
	int n,s,inputNum,minNum,maxNum;
	
	while(cin>>n,n){
		minNum=(int)1e+8;
		s=maxNum=0;
		
		for(int i=0;i<n;i++){
			cin>>inputNum;
			s+=inputNum;
			if(inputNum<minNum){
				minNum=inputNum;
			}
			if(inputNum>maxNum){
				maxNum=inputNum;
			}
		}
		
		s=s-maxNum-minNum;
		s=s/(n-2);
		
		cout<<s<<endl;
	}
}

C++: #include<iostream>
using namespace std;
int main(){
int judge;
int maxscore =0;
int minscore =0;
cin >> judge;
if(judge != 0){
int score[judge];
	for(int i=0; i<judge; i++){
	cin >> score[i];
		if(score[i] > maxscore){
		maxscore = score[i];
		}
		if(score[i] < minscore){
		minscore = score[i];
		}
		if(i==0){
		minscore = score[0];
		}
	}
int lastscore = 0;
for(int j=0;j<judge;j++){
lastscore +=  score[j];
}
lastscore = (lastscore - maxscore - minscore)/(judge - 2);
cout << lastscore <<endl;
}
return 0;
}

C++: #include <iostream>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <bitset>
#include <tuple>

using namespace std;

int main(void)
{
  while (true) {

    int n;
    cin >> n;
    if (n == 0) break;
    int p[n];
    for (int i = 0; i < n; i++)
      cin >> p[i];
    int top,bottom,sum;
    top = -1;
    bottom = 1001;
    sum = 0;
    for (int i = 0; i < n; i++) {
      if (top < p[i])
	top = p[i];
      if (bottom > p[i])
	bottom = p[i];
    }
    //cout << top << "  " << bottom << endl;
    
    bool t, b;
    t = b = true;
    for (int i = 0; i < n; i++) {
      if (top == p[i] && t) {
	t = false;
      }
      else if (bottom == p[i] && b) {
	b = false;
      }
      else
	sum+=p[i];
    }
    cout << (int)(sum/(n-2)) << endl;
    
  }
  return 0;	
}