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 <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <tuple>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    int sum=0,M=0,m=10000;
    REP(i,n){
      int tmp;
      cin >> tmp;
      sum+=tmp;
      if(M<tmp) M=tmp;
      if(m>tmp) m=tmp;
    }
    cout << (sum-M-m)/(n-2) << endl;
  }
}

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

using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0 ;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int sum=0;
    for (int i=0;i<n-1;i++){
        sum+=a[i];
    }
    cout << (float) sum /(float) (n-2)<<endl;
}

C++: #include<iostream>
#include<algorithm>
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<iostream>
using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        int sum = 0, mi = 1000, ma = 0, x;
        for(int i = 0; i < n; i++){
            cin >> x;
            sum += x;
            mi = min(mi, x);
            ma = max(ma, x);
        }
        cout << (sum-mi-ma)/(n-2) << endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	while(true){
		int n,sum=0,mx=-1,mn=100000;
		cin >> n;
		if(n==0) break;
		for(int i=0;i<n;i++){
			int s;
			cin >> s;
			mn=min(mn,s);
			mx=max(mx,s);
			sum+=s;
		}
		cout << (sum-mn-mx)/(n-2) << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	int x[1000];
	int y[20];
	int max;
	int min;
	n = 1;
		int j = 0;
		while (n != 0){
			
			cin >> n;
			max = 0;
			min = 1000;
				y[j] = 0;
			for (int i = 0; i < n; i++){
				cin >> x[i];
				if (max < x[i]) max = x[i];
				if (min > x[i]) min = x[i];
				y[j] += x[i];
			}
			y[j] -= max + min;
			y[j] = y[j] / (n - 2);
			j++;
		}
	for (int k = 0; k < j; k++){
		cout << y[j]<< endl ;
	}
	return 0;
}

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

int main() {
    int score[100];
    int i,j;
    int n;
    int tmp;
    int sum;
    int scorel;
    
    while(1){
        sum = 0;
        cin >> n;
        if(n == 0){
            break;
        }
        
        for(i = 0;i < n;i++){
            cin >> score[i];
        }
        
        for(i = 0;i < n - 1;i++){
            for(j = i + 1;j < n;j++){
                if(score[i] > score[j]){
                    tmp = score[i];
                    score[i] = score[j];
                    score[j] = tmp;
                }
            }
        }
        
        for(i = 1;i < n - 1;i++){
            sum = sum + score[i];
        }
        
        scorel = sum / (n - 2);
        
        cout << scorel << endl;
        
    }
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define vsort(v) sort(v.begin(),v.end())
#define asort(a,n) sort(a, a + n)
#define vi vector<int>
#define vd vector<double>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int N;
    int ans;
    int cnt;
    vi vec(20);
    while(true){
        vec.assign(20, -1);
        ans = 0;
        cnt = 0;
        cin >> N;
        if(N == 0) return 0;
        rep(i, N){
            cin >> vec[i];
        }
        vsort(vec);
        REP(i, 21 - N, 19){
            ans += vec[i];
            cnt++;
        }
        cout << (int)(ans / cnt) << endl;
    }


    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main() {
  int n;
  while(cin >> n && n) {
	vector<int> v(n, 0);
	for(int i = 0; i < n; ++i) {
	  cin >> v[i];
	}
	*min_element(v.begin(), v.begin() + n) = 0;
	*max_element(v.begin(), v.begin() + n) = 0;
	
	cout << accumulate(&v[0], &v[n], 0) / (n - 2) << endl;
  }

  return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





int main() {
    int n;
    cin >> n;
    
    while(n){
        double mn = 1e9, mx = 0, sum = 0;
        REP(i, n){
            double t;
            cin >> t;
            sum += t;
            mx = max(mx, t);
            mn = min(mn, t);
        }
        cout << (int)((sum - mx - mn) / (n - 2)) << '\n';
        
        cin >> n;
    }
}

C++: #include <stdio.h>

struct data {int score[100],n;} table[20];
struct data *d;

void sort(int *a,int n){
  int i,j,t;
  for(i=0; i<n-1; i++) for(j=n-1; j>i; j--)
  if(a[j-1]>a[j]) {t=a[j-1]; a[j-1]=a[j]; a[j]=t;}
}

int main(){
  int i,j,N,ave;
  for(i=0;; i++) {d=&table[i];
    scanf("%d",&d->n );
    if(d->n==0) break;
    for(j=0; j<d->n; j++) scanf("%d",&d->score[j] ); }
    N=i;
    for(i=0; i<N; i++) {d=&table[i];ave=0;
      sort(d->score,d->n);
      for(j=1; j<d->n-1; j++) ave+=d->score[j];
      ave/=d->n-2;
      printf("%d\n",ave);}
    }