Go: package main

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

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	for sc.Scan() {
		n, _ := strconv.Atoi(sc.Text())
		scores := make([]int, n, n)
		for i := 0; i < n; i++ {
			sc.Scan()
			scores[i], _ = strconv.Atoi(sc.Text())
		}
		sort.IntSlice(scores).Sort()
		var sum = 0
		for i := 1; i < n-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

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>

int N;

int getScore(int A[])
{
	int maxA, minA, lenA, total {};
	lenA = N - 2;
	maxA = *std::max_element(A, A + N);
	minA = *std::min_element(A, A + N);
	for (int i {}; i < N; ++i)
		total += A[i];
	total = total - minA - maxA;
	
	int score;
	score = total / lenA;
	return score;
}

int main()
{
	while (std::cin >> N && N > 0)
	{
		int a[N];
		for (int i {}; i < N; ++i)
			std::cin >> a[i];
		std::cout << getScore(a) << std::endl;
	}
}

C++: #include "bits/stdc++.h"

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

    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 s=0;
        for(int i=1;i<n-1;i++) s+=v[i];
        cout<<s/(n-2)<<endl;
    }
}

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

int N, S;
int main() {
	while(cin >> N && N > 0) {
		int sum = 0;
		int largest = 0;
		int smallest = 1000;

		for(int i = 0; i < N; i++) {
			cin >> S;
			sum += S;
			if(S > largest) largest = S;
			if(S < smallest) smallest = S;
		}

		sum = sum - largest - smallest;
		cout << sum << endl;

	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
bool solve(){
  int inum;
  vector<int> idata;
  cin >> inum;
  if(!inum)return false;
  for(int i=0;i<inum;i++){
    int buf;
    cin >> buf;
    idata.push_back(buf);
  }
  idata.erase( max_element(idata.begin(), idata.end()));
  idata.erase( min_element(idata.begin(), idata.end()));
  int sum = accumulate( idata.begin(), idata.end(), 0 ) / idata.size();
  cout << sum << endl;
  return true;
}

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

C++: #include<iostream>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<stack>
using namespace std;

int main(){
    int n;
    while(1){
        scanf("%d",&n);
        if(n==0)break;
        int sum=0,max=0,min=1000,point;
        for(int i=1;i<=n;i++){
            scanf("%d",&point);
            if(point>max) max=point;
            if(point<min) min=point;
            sum+=point;
        }
        printf("%d\n",(sum-max-min)/(n-2));
    }
    return 0;
}

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

int main()
{
while(true){
int n;
vector<int> s;
scanf("%d", &n);
if(n == 0)
break;
s.resize(n);
for(int i = 0; i < n; ++i)
scanf("%d", &s[i]);
sort(s.begin(), s.end());
int sum = 0;
for(int i = 1; i < n - 1; ++i)
sum += s[i];
printf("%d\n", sum / (n - 2));
}
return 0;
}

C++: //http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    while (true) {
        cin >> n;
        if (n == 0) return 0;

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


/*
 *
 */

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

int main(int argc, char const *argv[]) {
	int n, input;

	while(1) {
		cin >> n;
		if (n==0) break;
		vector<int> s;
		for (int i = 0; i < n; ++i)
		{
			cin >> input;
			s.push_back(input);
		}
		vector<int>::iterator maxiter = max_element(s.begin(), s.end());
		vector<int>::iterator miniter = min_element(s.begin(), s.end());
		vector<int>::iterator end_max = remove(s.begin(), s.end(), *maxiter);
		vector<int>::iterator end_min = remove(s.begin(), s.end(), *miniter);
		s.erase(end_max, s.end());
		s.erase(end_min, s.end());
		cout << endl;
		for (int i = 0; i < s.size(); ++i)
		{
			cout << s.at(i) << " ";
		}
		cout << endl;
		int ave = accumulate(s.begin(), s.end(), 0);
		ave /= s.size();
		cout << ave << endl;
	}


	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <iomanip>
#include <functional>
using namespace std;
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

int main(int argc, char* argv[])
{
	

	while(1){
		int ans=0;
		int i=0;
		int a;
		int ninzu;
		vector <int>  s;

		cin >> ninzu;

		for(i=0;i<ninzu;i++){
			cin >> a;
			if(a == 0)break;
			s.push_back(a);
		}
		sort( ALL(s) );

		for(i=1;i<s.size();i++){
			if(s[i] != 0)ans+= s[i];
		}
		ans -= s[i];

		ans = ans / (i-1);

		cout << ans << endl;
		ans=0;

	}

    return 0;
}