Go: package main

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

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

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

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

		score_list := []int{}
		for i := 0; i < num; 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))
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int a,b[100];
  while(1)
  {
    scanf("%s",&a );
    if(a == 0)
    {
      break;
    }

    for(int i=0; i<a; i++)
    {
      scanf("%d",&b[i] );
    }

    sort(b,b+a);

    int c = 0;
    for(int i=1; i < a-1; i++)
    {
      c+=b[i];
    }
    printf("%d\n",c / (a-2) );
  }
}

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

using namespace std;

#define FOR(i,s,e) for(int (i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define UNIQUE(o) (o).erase(unique(sort(all((o)))))

typedef long long ll;
const int N = 100;
const int S = 1000;
int n;
int c[S+1];

int main() {
  int s;
  scanf("%d ", &n);
  while (n) {
    memset(c, 0, sizeof(c));
    int res = 0;
    int max_idx = 0, min_idx = S;
    REP(i,n) {
      scanf("%d ", &s);
      c[s]++;
      max_idx = max(max_idx, s);
      min_idx = min(min_idx, s);
      res += s;
    }
    res -= max_idx;
    res -= min_idx;
    n -= 2;
    res /= n;
    printf("%d\n", res);
    scanf("%d ", &n);
  }

  return 0;
}

C++: #include <iostream>

using namespace std;
int main(){
	int zero;
	while(1){
		
		int N;
		int* score;
		int S = 0;
		int max = 0;
		int min = 0;
	
		cin >> N;
		
		if(N == 0){
			return 0;
		}
		
		score = new int[N];
		for(int i=0; i<N; ++i){
			cin >> score[i];
			S += score[i];
			
			if( i == 0 ){
				max = min = score[i];
			}
		
			if( max < score[i] ){
				max = score[i];
			}
			if( min > score[i] ){
				min = score[i];
			}
		}
		S -= max;
		S -= min;
	
		cout << (int)S/(N-2) << endl;

		delete[] score;
	}

}

C++: #include<bits/stdc++.h>
using namespace std;
#define OUT(x) cout<<x<<endl
#define debug(x) cout<<#x<<": "<<x
const int BA = 1000;
const int INFTY = (1<<21);
int main(){
  int n,ans;
  int s[1001];
  while(cin>>n&&n){
    ans = 0;
    for(int i=0;i<n;i++)cin >> s[i];
    
    sort(s,s+n);
    for(int i=1;i<n-1;i++)ans+=s[i];
    ans/=n-2;
    OUT(ans);
  }
}

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

using namespace std;

int main()
{
    int n;
    while(cin >> n, n)
    {
        int max_s, min_s, sum;
        cin >> max_s >> min_s;
        sum = max_s + min_s;
        if(max_s<min_s) swap(max_s, min_s);
        for(int i=2; i<n; i++)
        {
            int s;
            cin >> s;
            sum += s;
            if(max_s<s) max_s = s;
            if(min_s>s) min_s = s;
        }
        cout << (sum - max_s - min_s) / (n - 2) << endl;
    }
}

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

int main()
{
	int in,a,maxer=0,miner=1000;
	int sum=0;
	int i=0;
	double ave=0.0;
	while( cin >> in,in ){
		for(i=0; i<in; i++){
			cin >> a;
			maxer=max(a,maxer);
			miner=min(a,miner);
			sum += a;
		}
		sum = sum - maxer - miner;
		ave = sum/(in-2);
		cout << floor(ave) << endl;
		sum = maxer = ave = 0;
		miner=1000;
	}
}

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

int main() {
    for(;;){
        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);
        int ans=0;
        for (int i=1;i<n-1;i++) {
            ans+=a[i];
            }
        cout<<ans/(n-2)<<"\n";
        }
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
    
    cin.tie( 0 );
    ios::sync_with_stdio( false );
    
    while(true){
        int n;
        cin >> n;
        
        if(n == 0){ break; }
        vector<int> vc(n);
        
        for(int i=0; i<n; i++){
            cin >> vc[i];
        }
        auto mm = minmax_element(vc.begin(),vc.end());
        auto res = (accumulate(vc.begin(), vc.end(), 0)) - (*mm.first + *mm.second);
        cout << res / (n-2) << endl;
    }
    return 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;
		}
	}
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;
}