Go: /*
	Problem A: ICPC 得点集計ソフトウェア
	http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// 標準入力を取得するScannerのインスタンスを作成
var sc = bufio.NewScanner(os.Stdin)

// 標準入力で各行を読み込み文字列として返す
func readLine() string {
	if sc.Scan() {
		return sc.Text()
	}
	return ""
}

func average() (avg int) {
	// 審判の人数を取得する
	n, _ := strconv.Atoi(readLine())

	// 得点
	score := make([]int, 0, n)

	// 得点を読み込む
	for n > 0 {
		line, _ := strconv.Atoi(readLine())
		score = append(score, line)
		n--
	}

	if len(score) == 0 {
		return 0
	}

	// ソート
	sort.Ints(score)
	// 先頭を削除
	score = append(score[:0], score[1:]...)
	// 末尾を削除
	score = score[:len(score)-1]

	// 合計
	for i := 0; i < len(score); i++ {
		avg += score[i]
	}

	// 平均
	avg = avg / len(score)
	return avg
}

func main() {
	// 改行区切りから単語(スペース)区切りで読み込むように変更する
	sc.Split(bufio.ScanWords)
	for {
		avg := average()
		if avg != 0 {
			fmt.Println(avg)
		} else {
			break
		}
	}
}

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<stdio.h>
#include<math.h>
#define MAX 1000

int main(void){
	
	int i,n,max,min,sum,a[100],t;
	
	while(t != 1){

scanf("%d",&n);

if(n != 0){
	for(i = 0 ; i < n ; i++){
		a[i] = 0;
	}
	sum = 0;
	for(i = 0 ; i < n ; i++){
	scanf("%d",&a[i]);
	sum = sum + a[i];
	}
	max = a[0];
	for(i = 0 ; i < n ; i++){
		if(max < a[i]){
			max = a[i];
		}
	}
	
	min = a[0];
	for(i = 0 ; i < n ; i++){
		if(min > a[i]){
		min = a[i];
		}
	}
	
	sum = sum - max - min;
	
	n = n - 2;
	printf("%d\n",sum/n);
	
}

if(n == 0){
t = 1;
}

}

return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
	int n;
	int sum, max, min;
	
	while( 1 ){
		sum = 0; max = 0; min = 1000;
		cin >> n;
		vector<int> score(n);
		if( n == 0 ) break;
		for( int i = 0; i < n; i++ ){
			cin >> score[i];
			sum += score[i];
			if( max < score[i] ) max = score[i];
			if( min > score[i] ) min = score[i];
		}
		sum -= max + min;
		cout << sum/(n-2) << endl;
		score.clear();
	}
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = 3.141592653589793;
int n;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (cin >> n,n) {
        int  s[105]={};
        rep(i,n) cin >> s[i];
        sort(s,s+n);
        int ans=0;
        rep2(i,1,n-1) ans+=s[i];
        cout << ans /(n-2) << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

void print_vec(vector<int> vec)
{
  cout << "[";
  for (int i = 0; i < vec.size(); i++)
  {
    cout << vec.at(i);
    if (i < vec.size() - 1)
    {
      cout << ", ";
    }
  }
  cout << "]...size: " << vec.size() << endl;
}

int main()
{
  vector<int> vec;

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

    int least = 1001;
    int most = 0;
    int sum = 0;

    rep(i, n)
    {
      int x;
      cin >> x;
      least = min(least, x);
      most = max(most, x);
      sum += x;
    }

    int ave = (sum - least - most) / (n - 2);
    vec.push_back(ave);
  }

  for (auto &&i : vec)
  {
    printf("%d\n", i);
  }
}

C++: #include<iostream>
using namespace std;
 
int main(){
    int n,i;

    while(1){
        int point[100]={0,};
        int min = 1000;
        int max = 0;
		long total = 0;
        cin >> n;
        if(!n) break;
        for(i=0;i<n;i++){
            cin >> point[i];
            if(point[i] > max) max = point[i];
            if(point[i] < min) min = point[i];
			total += point[i];
        }
        cout << (total-max-min)/(n-2) << "\n";
    }

}

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

int main() {
  int n;
  while (cin >> n && n) {
    int s[110];
    for (auto i=0; i<n; i++) {
      cin >> s[i];
    }
    int max = 0;
    int min = 1010;
    int sum = 0;
    for (auto i=0; i<n; i++) {
      sum += s[i];
      if (max < s[i]) max = s[i];
      if (min > s[i]) min = s[i];
    }
    cout << (sum - max - min)/(n-2) << endl;
  }
}

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define INF 1e09

using namespace std;

int main(){
  int n;
  int total, maxim, minim;
  int tmp;
  while(cin >> n){
    total = 0; maxim = -INF; minim = INF;
    REP(i, n) { cin >> tmp; total += tmp; maxim = max(maxim, tmp); minim = min(minim, tmp); }
    total -= (maxim + minim);
    cout << total / (n - 2) << endl;
  }
  return 0;
}

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

//vector??????????§£???
int main(){
	while (1){
		int n;
		cin >> n;
		//???????????¶
		if (n == 0) break;
		//??\???
		vector<int> num;
		for (int i = 0; i < n; i++){
			int tmp;
			cin >> tmp;
			num.push_back(tmp);
		}
		//????¨????????°????????????§???????¨????
		int max = -1;
		int min = 99999;
		int sum = 0;
		for (int i = 0; i < num.size(); i++){
			if (num[i] >= max) max = num[i];
			if (num[i] <= min) min = num[i];
			sum += num[i];
		}
		//??????????¨????
		int avg = floor((sum - max - min) / (n - 2));
		cout << avg << endl;
	}
	return 0;
}