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())
		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 < n-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

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;	
}

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

int main(){
  while (1){
    int n,p,sum=0;
    cin >> n;
    if (n==0) return 0;
    vector<int> points;
    for(int i=0;i<n;i++){
      cin >> p;
      points.push_back(p);
    }
    sort(points.begin(),points.end());
    points.erase(points.begin());
    points.pop_back();
    for (int i=0;i<points.size();i++){
      sum+=points[i];
    }
    cout << floor(sum/points.size()) << endl;
  }
}

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

int main(){
  int n;
  int maxs,mins,sum;
  while(cin>>n,n){
    sum=0;
    maxs=0;
    mins=2000;
    for(int i=0,tmp;i<n;i++){
      cin>>tmp;
      sum+=tmp;
      maxs=max(maxs,tmp);
      mins=min(mins,tmp);
    }
    sum-=mins;
    sum-=maxs;
    cout<<sum/(n-2)<<endl;
  }
}