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){
  while(1){
    int n;
    cin >> n;
    if(n == 0){return 0;}

    int point[n];
    for(int i = 0 ; i < n ; i++){
      cin >> point[i];
    }

    int sum = 0;
    int max = -1;
    int min = 1001;
    for(int i = 0 ; i < n ; i++){
      if(max < point[i]){max = point[i];}
      if(min > point[i]){min = point[i];}

      sum += point[i];
    }

    cout << (int)(sum - max - min)/(n - 2);
  }

}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>

using namespace std;

int n;
int s;
vector<int> v;
int f;
int b;
int sum = 0;
int ans = 0;

int main() {

	while (cin >> n) {
		if (n == 0) break;
		for (int i = 0; i < n; i++) {
			cin >> s;
			v.push_back(s);
		}

		sort(v.begin(), v.end());

		f = v[0];
		b = v[v.size() - 1];

		for (int i = 0; i != v.size(); ++i) {
			sum += v[i];
		}
		sum = sum - f - b;
		ans = sum / (v.size() - 2);

		cout << ans << endl;

		v.clear();
		sum = 0;
		ans = 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;
		}
		if(i==0){
		minscore = score[0];
		}
	}
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>
using namespace std;

int main(){
        int i = 0;
        
        while(cin >> i && !(i == 0)){
                int a[i];
                int j = 0;              

                for(j=0; j<i; j++){
                        cin >> a[j];
                }
                cout << endl;           
        
                //sum
                int sum = 0;
                for (j=0; j<i; j++) {
                        sum += a[j];
                }
        
                //largest,smallest
                int largest = 0;
                int smallest = 1000;
                for (j=0; j<i; j++){
                        if (a[j] > largest)
                                largest = a[j];
                        else if (a[j] < smallest)
                                smallest = a[j];
                }
                
                //average
                int average = 0;
                average = (sum - largest - smallest) / (i - 2);
                cout << average;
        }
}

C++: 

while true do
    max = -1
    min = 1001
    sum = 0
    n = gets.to_i
    n.times do
        v = gets.to_i
        min = v if v < min
        max = v if v > max
        sum += v
    end
    sum -= (min + max)
    p sum / (n-2)
end

C++: #include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define rFOR(i, a, b) for(int i=b-1; i>=a; i--)
#define MAX 20
using namespace std;

int main(void){
  while(true){
    int n;  cin >> n;
    if(n==0)  break;
    int s[MAX], sum=0;
    rep(i, n) cin >> s[i];
    sort(s, s+n);
    FOR(i, 1, n-1)  sum += s[i];
    cout << sum/(n-2) << endl;

  }
  return 0;
}

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

int s;
int n,maxn,minn,sum;
int main(){
	while(1){
		cin >> n;
		if(n==0)break;
		minn=1001;
		maxn=0;
		for(int i=0;i<n;i++){
			cin >>s;
			sum+=s;
			if(maxn<s)maxn=s;
			if(minn>s)minn=s;
		}
		sum=sum-minn-maxn;
		cout <<sum/(n-2)<<endl;


	}
	return 0;
}

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

int main(){
	int n; 
	while( cin >> n, n ){
		vector<int> s(n);
		for(int i=0 ; i < n ; i++ ){
			cin >> s[i];
		}
		sort( s.begin(), s.end() );
		int sum = 0;
		for(int i=1 ; i < s.size()-1 ; i++ ){
			sum += s[i];
		}
		cout << (sum / (s.size() - 2)) << endl;
	}
}

C++: #include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

using namespace std;


int main()
{
    int n;
    while(1){
        cin >> x;
        if(x == 0) break;
        int max = -1, mini = 10000, sum = 0, ten = 0, y = 0;
        for(int i = 0; i < x; i++){
            cin >> ten;
            sum += ten;
       	    if(ten > max) max = ten;
            if(ten < mini) mini = ten;
	    
        }
        sum -= max + mini;
        y = sum / (x - 2);
        cout << y << endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define CHMIN(a,b) (a) = min((a),(b))
#define CHMAX(a,b) (a) = max((a),(b))

int main()
{
    int in;
    int num;
    int ans=0;
    int point[105]={};
    while(1==1)
    {
        
        scanf("%d\n",&in);
        if(in==0)return 0;
        num=in;
        ans=0;
        REP(i,num)
        {
            scanf("%d\n",&point[i]);
            ans+=point[i];
        }
        sort(&point[0],&point[num]);
        ans-=(point[0]+point[num-1]);
        printf("%d\n",ans/(num-2));
    }
    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 <cstdio>
#include <algorithm>
using namespace std;

int s[100];

int main(){
	int n;
	while(scanf("%d", &n),n){
		for(int i = 0; i < n; i++) scanf("%d", &s[i]);
		sort(s,s+n);
		int sum = 0;
		for(int i = 1; i < n-1; i++){
			sum += s[i];
		}
		printf("%d\n", sum/(n-2));
	}
}

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

int compare(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}

int main(void) {
	int n;
	int score[1024];

	while (true) {
		std::cin >> n;
		if (!n) break;

		for (int i = 0; i < n; i++) std::cin >> score[i];

		qsort(score, n, sizeof(int), compare);
		double sum = 0;
		for (int i = 1; i < n - 1; i++) sum += score[i];
		int ave = int(sum / (n-2));
		std::cout << ave << '\n';
	}
	return 0;
}