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 <cstdlib>
using namespace std;

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

int main() {
	int n;
	while (1) {
		cin >> n;
		if (n == 0) break;
		int points[n];
		for (int i = 0; i < n; i++) {
			cin >> points[i];
		}
		qsort(points, n, sizeof(int), comp);
		int sum = 0;
		for (int i = 1; i < n - 1; i++) {
			sum += points[i];
		}
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n,s[120],count;;
	while(true){
		cin>>n;
		count=0;
		for(int i=0;i<n;i++){
			cin>>s[i];
			count+=s[i];
		}
		for(int i=0;i<n-1;i++){
			for(int j=n-1;j>i;j--){
				if(s[j]<s[j-1]){
					int tmp=s[j];
					s[j]=s[j-1];
					s[j-1]=tmp;
				}
			}
		}
		count-=s[0];
		count-=s[n-1];
		cout<<count/(n-2)<<endl;
	}
    return 0;
}

C++: #include<iostream>
#include<algorithm>
 
using namespace std;
 
int main(){
    while( true ){
        int n;
        cin >> n;

        if (n == 0) break;

        int a[n];

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

        sort(a,a+n);

        for(int i=2;i<n-1;i++){
            a[1]+=a[i];
        }

        cout<<a[1]/(n-2)<<endl;

    }   
    return 0; 
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> p;
#define le 1000000007;
int main(){
  while(1==1){
  int n;
  cin >> n;
  if(n==0)break;
  long long int sum=0;
  vector<int> v(n,0);
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  for(int i=1;i<n-1;i++){
    sum+=v[i];
  }
  cout << sum/(n-2) << endl;
  }
  return 0;
}

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

int main() {
	int N;
	while (cin >> N) {
		if (N == 0) break;
		int A, COUNT = 0, MAX = 0, MIN = 10000;
		for (int i = 0; i < N; i++) {
			cin >> A;
			COUNT += A;
			MAX = max(MAX, A);
			MIN = min(MIN, A);
		}
		cout << (COUNT - MAX - MIN) / (N - 2) << endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
const int MAX_N=101;

int n,ans;
vector<int> s(MAX_N);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n,n){
        for (int i=0;i<n;++i) cin >> s[i];
        sort(s.begin(),s.begin()+n);
        ans=0;
        for (int i=1;i<n-1;++i) ans+=s[i];
        cout << ans/(n-2) << '\n';
    }
}

C++: #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

#define Rep(b, e, i) for (int i = b; i <= e; i++)
#define Repr(e, b, i) for (int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n - 1, i)
#define repr(n, i) Repr(n - 1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)), (x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; // Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int>>
    IntReversePrioQueue; // A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1 << 31 - 1;
const int MOD = 1000000007;

void solve(void) {
  while (1) {
    int N;
    scanf("%d\n", &N);
    if (N == 0)
      break;
    vector<int> ps;
    rep(N, i) {
      int p;
      scanf("%d\n", &p);
      ps.pb(p);
    }
    sort(all(ps));
    int ans = ps[0] + ps[N - 1];
    for (int t : ps) {
      if (t != ps[0] && t != ps[N-1]) ans += t;
    }
    printf("%d\n", ans / N);
  }
}

int main(void) {
  solve();
  return 0;
}

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

using namespace std;

int main(){
     int N;
     while(cin>>N,N){
	  multiset<int> ten;
	  for(int i=0;i<N;i++){
	       int temp;
	       cin>>temp;
	       ten.insert(temp);
	  }
	  multiset<int>::iterator itr=ten.begin();
	  ten.erase(itr);
	  multiset<int>::reverse_iterator ritr=ten.rbegin();
	  ritr++;
	  ten.erase(ritr.base());
	  itr=ten.begin();
	  int sum=0;
	  while(itr!=ten.end()){
	       sum+=*itr;
	       itr++;
	  }
	  cout<<(int)sum/ten.size()<<endl;
     }
}

C++: #include <cstdio>

using namespace std;

int main(){
  int min,max,sum,n,score;

  while(1){
    scanf=0("%d",&n);
    if(!n) break;

    max=0;min=10000;sum=0;

    for(int i=0;i<n;i++){
        scanf("%d",&score);
        if(max<score) max=score;
        if(min>score) min=score;
        sum+=score;
    }

    printf("%d\n",(score-max-min)/(n-2));
}
    return 0;
}

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

using namespace std;

int main(void){

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

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

int main(){
  int n,s[100],num,max=s[0],min=s[0];
  
  while(n != 0){
  cin>>n;    
    num=0;
    
  for(int i=0;i<n;i++){
    cin>>s[i];

    if(max<s[i])max=s[i];
    if(max>s[i])min=s[i];
       
    num += s[i];
  }
  num = (num-max-min)/n;
    cout<<num<<endl;

  }
  return 0;
}