Go: // ICPC 得点集計ソフトウェア
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for	{
		n := nextInt(sc)
		if n == 0 { break }

		score_list := []int{}
		for i := 0; i < n; i++ {
			score_list = append(score_list, nextInt(sc))
		}

		// 最低点と最高点を取り除く (3 ≤ n ≤ 100)
		sort.Sort(sort.IntSlice(score_list))
		score_list = score_list[1:len(score_list)-1]

		// 平均点を求める
		sum := 0
		for _, score := range score_list {
			sum += score
		}
		fmt.Println(sum / len(score_list))
	}
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

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){
  s++;
  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<algorithm>
using namespace std;

int main(void){
	int n;
	int *tokuten;
	int maxi=0,mini=1000;
	int goukei=0,cnt=0;
	int *heikin=new int[100];
	while(1){
		cin>>n;
		int i=0;
		if(n==0)
			break;

		tokuten=new int[n];
		maxi=0;
		mini=1000;
		for(i=0;i<n;i++){
			cin>>tokuten[i];
			maxi=max(maxi,tokuten[i]);
			mini=min(mini,tokuten[i]);
			goukei+=tokuten[i];
		}
		
		
		goukei=goukei-(mini+maxi);
		goukei=goukei/(n-2);
		heikin[cnt]=goukei;
		goukei=0;
		cnt++;
		delete[] tokuten;
		
	}
	for(int j=0;j<cnt;j++)
		cout<<heikin[j]<<endl;
	delete[] heikin;
	
	return 0;
}

C++: #include<iostream>
using namespace std;
 
int main(){
    int n,i;
    while(cin >> n,n){
        //int point[100]={0,};
		int p;
        int min = 1000;
        int max = 0;
		int total = 0;
        for(int i=0;i<n;i++){
            //cin >> point[i];
			cin >> p;
            //if(point[i] > max) max = point[i];
			if(p > max) max = p;
            //if(point[i] < min) min = point[i];
			//total += point[i];
			if(p < min) min = p;
			total += p;
        }
        cout << (total-max-min)/(n-2) << "\n";
    }

}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n;
    while(1) {
        cin >> n;
        if (n == 0) return 0;
        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 = 1; i < n-1; i++) {
            sum += a[i];
        }
        cout << (int)sum/(a.size()-2) << endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    while (true) {
        int s;
        cin >> s;
        if (s == 0)
            return 0;
        int tot = 0;
        int nax = -1, nin = 10000;
        for (int i = 0; i < s; ++i) {
            int x;
            cin >> x;
            chmax(nax, x);
            chmin(nin, x);
            tot += x;
        }
        cout << (tot - nax - nin) / (s - 2) << "\n";
    }
    return 0;
}

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

int main()
{
    int n,s;
    int sum = 0;
    std::vector<int> v;
    cin >> n;

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

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

    for(int i = 1; i < v.size() -1 ; i++)
    {
        sum += v[i];
    }
    int ave = sum / (v.size() - 2);
    cout << ave <<endl;
    return 0;
}

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

int main(){
  int n,s;
  vector<int> ss;
  while(1){
    cin>>n;
    //    cout<<"::"<<n<<endl;
    if(n==0)break;
    ss.clear();
    int i,j,k;
    for(i=0;i<n;i++){
      cin>>s;
      ss.push_back(s);
    }
    sort(ss.begin(),ss.end());
    int re=0;
    for(i=1;i<ss.size()-1;i++)
      re+=ss[i];
    re/=ss.size()-2;
    cout<<re<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
    int n,a[100],s;
    while(cin >> n,n){
        s = 0;
        for(int i = 0;i < n;++i){
            cin >> a[i];
        }
        sort(a,a+n);
        for(int i = 1;i < n-1;++i){
            s += a[i];
        }
        cout << s/(n-2) << endl;
    }
    return 0;
}

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

int n, a[110];

int main(){
	while(cin >> n && n > 0){
		int mins = 1010;
		int maxs = 0;
		int sum = 0;
		for(int i=0; i<n; ++i){
			cin >> a[i];
			mins = min(mins, a[i]);
			maxs = max(maxs, a[i]);
			sum += a[i];
		}
		int ans = (sum - mins - maxs) / (n-2);
		cout << ans << endl;
	}
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(void){
	int n;
	int s[1000];
	while(cin >> n && n>0){
		for(int i=0; i<n; i++){
			cin >> s[i];
		}
		sort(s, s+n);
		int sum = 0;
		for(int i=1; i<n-1; i++){
			sum += s[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)break;
		int _max = 0, _min = 1001, s, ans = 0, i = 0;
		for (i; i < n; ++i) {
			cin >> s;
			ans += s;
			_max = max(_max, s);
			_min = min(_min, s);

		}
		ans -= _max + _min;
		ans = int(ans / (n - 2));
		cout << ans << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

int main(){
	int n;
	int data[128];
	while(scanf("%d",&n),n){
		rep(i,n)scanf("%d",data+i);
		sort(data,data+n);
		int sum = 0;
		REP(i,1,n-1)sum+=data[i];
		printf("%d\n",sum/(n-2));
	}
	return 0;
}