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

C++: 
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>

#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main() {
	
	int N;

	while(cin >> N && N)
	{
		vector<int> score(N,0);
		rep(i, N){
			cin >> score[i];
		}

		int max_s = *max_element(ALL(score));
		int min_s = *min_element(ALL(score));

		//dump(max_s); dump(min_s);

		rep(i,N){if(score[i]==max_s){score.erase(score.begin()+i);break;}}
		rep(i,N){if(score[i]==min_s){score.erase(score.begin()+i);break;}}
	
		//DUMP(score);

		int ave = accumulate(ALL(score),0) / score.size();
		
		cout << ave << endl;
	}

	return 0;
}

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

using namespace std;

int main()
{
  while(true){
    unsigned int n;
    cin >> n;

    if(n == 0) break;

    unsigned int min_val = UINT32_MAX;
    unsigned int max_val = 0;
    unsigned int count = 0;
    for(unsigned int i = 0; i < n; i++){
      unsigned int val;
      cin >> val;
      min_val = min(val, min_val);
      max_val = max(val, max_val);
      count += val;
    }
    cout << (count - min_val - max_val) / (n -2) << endl;
  }
  
  return 0;
}

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

int main(void)
{
	int num,n,max,min,sum,ave,i;
	
	while(cin >> num){
		if(num == 0){
			break;
		}

		sum = 0;
		ave = 0;
		for(i = 0; i < num; i++){
			cin >> n;
			if(i == 0){
				max = n;
				min = n;
			}else{
				if(max < n){
					max = n;
				}
				if(min > n){
					min = n;
				}
			}
			sum += n;
		}
		sum = sum - max - min;
		ave = sum / (num - 2);
		cout << ave<< endl;
	}

	return 0;
}

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

int main()
{
  int n;
  int kazu=0,sum=0;
  int max,min;

  while(1)
    {
      cin >> n;

      if(n == 0)break;

      sum = 0;

      for(int i = 0;i < n;i++)
	{
	  cin >> kazu;
	  sum += kazu;

	  if(i == 0)
	    {
	      max = kazu;
	      min = kazu;
	    }

	  if(max < kazu) max = kazu;

	  if(kazu < min) min = kazu;
	}
      sum = sum - max - min;

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

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


int main(){
  int n;
  int score;
  while(cin >> n && n){
    int lc = 1000;
    int uc = 0;
    score = 0;
    for(int i = 0; i < n; i++){
      int num;
      cin >> num;
      score += num;
      lc = min(lc, num);
      uc = max(uc, num);
    }
    cout << (score - uc - lc) / (n - 2) << endl;
  }
  return 0;
}

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

int main(){
    int n;
    while(cin >> n, n != 0){
        int sum = 0, maxi = 0, mini = 1000;
        for(int i=0;i<n;++i){
            int s;
            cin >> s;
            sum += s;
            maxi = max(maxi, s);
            mini = min(mini, s);
        }
        cout << (sum- maxi - mini) / (n - 2) << endl;
    }

    return 0;
}

C++: #include<stdio.h>
#include<iostream>
using namespace std;
int main() {
	int a;
	while (cin >> a, a) {
		int sum=0; 
		int d;
		int f;
		int e = 0;
		for (int i = 0; i < a; i++) {
			cin >> d;
			if (i == 0) {
				f = d;
				e = d;
			}
			if (d > e) {
				e = d;
			}
			if (f > d) {
				f = d;
			}
			sum += d;
		}
		sum = sum - (e + f);
		sum = sum / (a-2);
		cout << sum << endl;
	}
}

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

using namespace std;
typedef long long ll;

int main(){
    
    ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    while(n){
        int a[n];
        int mini = INT_MAX, maxi = INT_MIN;
        int mincnt=0, maxcnt=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
            mini = min(mini, a[i]);
            maxi = max(maxi, a[i]);
        }
        for(int i=0;i<n;i++){
            if(a[i]==mini)  mincnt++;
            else if(a[i]==maxi) maxcnt++;
        }
        //cout<<mini<<" "<<mincnt<<" "<<maxi<<" "<<maxcnt<<endl;
        int sum=0;
        int cnt=0;
        for(int i=0;i<n;i++){
            if(a[i]==mini && mincnt>1){
                sum +=a[i];
                cnt++;
                mincnt--;
            }
            else if(a[i]==maxi && maxcnt>1){
                sum +=a[i];
                cnt++;
                maxcnt--;
            }
            else if((a[i]!=mini) && (a[i]!=maxi)){
                sum +=a[i];
                cnt ++;
            }
        }
        cout<<sum/cnt<<endl;
        cin>>n;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int judge;
int maxscore =0;
int minscore =0;
int maxnum=0;
int minnum=0;
cin >> judge;
int score[judge];
	for(int i=0; i<judge; i++){
	cin >> score[i];
		if(score[i] > maxscore){
		maxscore = score[i];
		maxnum=i;
		}
		if(score[i] < minscore){
		minscore = score[i];
		minnum=i;
		}
	}
score[maxnum] = 0;
score[minnum] = 0;
int lastscore = 0;
for(int j=0;j<judge;j++){
lastscore = lastscore +  score[j];
}
lastscore = lastscore/(judge - 2);
cout << lastscore <<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 <queue>
using namespace std;

int main(int argc, char const *argv[]){
	int n;
	priority_queue<int> que;

	while(1){
		int total = 0;
		int i;
		cin>>n;
		if (n==0) break;
		for (int i = 0; i < n; i++){
			int tmp;
			cin>>tmp;
			que.push(tmp);
		}
		que.pop();
		int m = que.size()-1;
		for (i = 0; i < m; i++){	
			total += que.top();
			que.pop();
		}
		cout<<total/i<<endl;
		que.pop();
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main (){
    while(true){
    int n;
    cin >> n;
    int max=0;
    int min = 10000;
    int sum = 0;
    int x;
    int count =0;
    
    if(n==0)return 0;
    for(int i=0;i<n;i++){
        cin >> x;
        if(min>x)min=x;
        if(max<x)max=x;
        sum = sum + x;
        count++;
    }
    int average;
    average = (sum -min -max)/(count-2);
    cout << average << endl;
    }

}