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

}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int main(){
    while(true){
        int n; cin >> n; if(n ==0 ) break;
        int sum = 0; int cou = 0;
        vi v(n,INF);
        rep(i,n){cin >> v[i];}

        sort(v.begin(),v.begin()+n);
        v.erase(v.begin());
        v.erase(v.end()-1);
        rep(i,n-2){
            sum+=v[i]; cou++;
        }
        cout << sum /cou << endl;
    }
}

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

int main(void){
	int n;
	while(cin >> n,n){
		int sum=0,cmin=1001,cmax=-1;
		for(int i=0;i<n;i++){
			int tmp;
			cin >> tmp;
			sum+=tmp;
			cmin=min(cmin,tmp);
			cmax=max(cmax,tmp);
		}
		sum-=(cmin+cmax);
		n-=2;
		cout << sum/n << endl;
	}
	return 0;
}