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 <stdio.h>
#include <float.h> 
int main(void){	
  int n[10];	
  int a[1000];	
  int i,j,max[10],min[10],suma[10],sumb[10],ave[10]; 
  for(i = 0;;i++){  
    scanf("%d",&n[i]);
    if(n[i]==0)break;  
    for(j=0 ; j<n[i] ;j++){ 
      scanf("%d",&a[j]);
    } 
    max[i] = a[0];
    min[i] = a[0];
    suma[i] = 0; 
    for(j=0 ; j<n[i] ; j++){
      if(a[j] >= max[i]){
	max[i] = a[j];
      }
      if(a[j] <= min[i]){
	min[i] = a[j];
      }
      suma[i] += a[j];
    }
  } 

  for(j = 0;j < i;j++){
    sumb[j] = suma[j]-max[j]-min[j]; 
    n[j] -= 2;
    ave[j] = sumb[j] / n[j] ;
    printf("%d\n",ave[j]);    
  }
  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);
    }
    return 0;
}

C++: #include<stdio.h>

int main(){

  int n,a[105],sum,min,max,i;
  double ave;
  printf("suc");
  for(i=0;i<21;i++){
    scanf("%d",&n);
    if(n==0)
      break;
    else{
      sum = 0;
      min = 1000;
      max = 0;
      for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum += a[i];
      }
      for(i=0;i<n;i++){
        if(min>a[i])min=a[i];
        if(max<a[i])max=a[i];
      }
      ave = (sum - min -max)/(n-2);
      printf("%f",ave);
    }
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define PREP(i, m, n) for(int i = m; i < n; i++)
#define MREP(i, m, n) for(int i = m - 1; i >= n; i--)

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define prime first
#define weight second
#define MP make_pair
#define PB push_back

using namespace std;

int main(){
	int n = 0;
	while(cin >> n && n != 0){
		map<int, int> ev;
		int max = -1, min = 1001;
		
		rep(i, n){
			int s = 0;
			cin >> s;

			if(s > max) max = s;
			if(s < min) min = s;

			if(ev.find(s) != ev.end()) ev[s]++;
			else ev[s] = 1;
		}

		ev[max]--;
		ev[min]--;

		int result = 0, factor = 0;
		
		for(map<int, int>::iterator it = ev.begin(); it != ev.end(); it++){
			rep(i, it->second){
				result += it->first;
				factor++;
			}
		}

		cout << result / factor << endl;
	}
	

	return 0;
}

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

using namespace std;

int main()
{
	int n;

	while (scanf("%d", &n), n){
		vector<int> v;

		for (int i = 0; i < n; i++){
			int s;

			scanf("%d", &s);

			v.push_back(s);
		}

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

		v[0] = v[n - 1] = 0;

		int sum = 0;

		for (int i = 0; i < n; i++){
			sum += v[i];
		}

		printf("%d\n", sum / (n - 2));
	}

	return (0);
}

C++: #include <iostream>
using namespace std;
int main(){
    int a, b, c, d, max, min;
    
    while(1){c = 0;
        max = 0;
        min = 2000000000;
        cin >> a;
        if(a == 0){break;}
        for(int i=0;i<a;i++){
            cin >> b;
            if(b>max){
                max = b;
            }
            if(b<min){
                min = b;
            }
            c = c + b;
        }
        c = c - max - min;
        d = c / (a-2);
        cout << d << endl;
    }
    
    
    
    
    
    
    return 0;

}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
  int n;
  int point[20], average;
  
  while(1){
    average = 0;
    cin >> n;
    if(n < 3) break;

    for(int i = 0 ; i < n ; i++){
      cin >> point[i];
    }
    sort(point, point + n);
    for(int i = 1 ; i < n - 1 ; i++){
      average += point[i];
    }
    average /= (n-2);
    cout << average << endl;
  }
  return 0;
}

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

using namespace std;

int main()
{
	int n = -1;

	vector<int> score;

	while (true)
	{
		int sum = 0;

		cin >> n;

		if (n == 0) { break; }

		vector<int> D(n);

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

			sum += D[i];
		}

		sum -= *max_element(D.begin(), D.end());
		sum -= *min_element(D.begin(), D.end());

		score.push_back(static_cast<int>(sum / (D.size() - 2) + 0.5));
	}

	for (int i = 0; i < score.size(); i++)
	{
		cout << score[i] << endl;
	}

	return 0;
}

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

int main()
{
	int N, n, sum, largest, smallest;
	sum  = 0; largest = 0; smallest = 1000;
	
	while(cin >> N && N>0){
		for(int i = 0; i<N; i++)
		{
			cin >> n;
			sum += n;
			
			if(smallest > n){ smallest = n;}
			if(largest < n){ largest = n;}
		}
	
		cout << (sum-smallest-largest)/(N-2) << endl;
	}
}

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

int main() {
int i,n,x,y,a[20],ans;
	while(1){
		scanf("%d",&n);
		if(n == 0)break;
		x = 0;
		y = 0;
		ans = 0;
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
		if(a[x] < a[i])x = i;
		if(a[y] > a[i])y = i;
			ans += a[i];
		}
		ans = ans - a[x] - a[y];
		ans = ans / (n-2);
		printf("%d\n",ans);
	}
	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];
                }
        
                //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];
                        if (a[j] < smallest)
                                smallest = a[j];
                }
                
                //average
                int average = 0;
                average = (sum - largest - smallest) / (i - 2);
                cout << average << endl;
        }

}