Go: package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	for n != 0 {
		arr := make([]int, n)
		for i := range arr {
			fmt.Scan(&arr[i])
		}
		sort.Ints(arr)

		sum := 0
		for i := 1; i < len(arr)-1; i++ {
			sum += arr[i]
		}
		fmt.Println(sum / (n - 2))
		fmt.Scan(&n)
	}
}

C++: #include <stdio.h>

int main(void) {
	int count;
	int point[200][2/*x,y*/];

	int n,d;

	while(1) {
		scanf( "%d", &count );
		if ( count == 0 ) { break; }
		
		int xmin,xmax,ymin,ymax;
		xmin=0, xmax=0, ymin=0, ymax=0;
		
		point[0][0]=0;
		point[0][1]=0;
		for ( int i=1; i<count; i++ ) {
			scanf("%d %d", &n, &d);

			switch ( d ) {
			case 0: //left
				point[i][0] = point[n][0]-1;
				point[i][1] = point[n][1];
				break;
			case 1: //down
				point[i][0] = point[n][0];
				point[i][1] = point[n][1]-1;
				break;
			case 2: //right
				point[i][0] = point[n][0]+1;
				point[i][1] = point[n][1];
				break;
			case 3: //up
				point[i][0] = point[n][0];
				point[i][1] = point[n][1]+1;
				break;
			}
			
			if ( xmax < point[i][0] ) { xmax = point[i][0]; }
			if ( xmin > point[i][0] ) { xmin = point[i][0]; }
			if ( ymax < point[i][1] ) { ymax = point[i][1]; }
			if ( ymin > point[i][1] ) { ymin = point[i][1]; }
		}
		
		printf("%d %d\n", xmax-xmin+1, ymax-ymin+1);
	}
	
	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
  int n=3;
  int point[20], average;
  
  while(1){
    average = 0;
    cin >> n;
    if(n == 0) 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 <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007ll;


int main(){
	for(;;){
		int n;
		std::cin >> n;
		if(n==0){
			exit(0);
		}else{
			std::vector<int> a(n);
			rep(i,n)std::cin >> a[i];
			sort(all(a));
			std::cout << accumulate(a.begin()+1,a.end()-1,0)/(n-2) << std::endl;
		}
	}
}

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

int main(){
	while(1){
				int n,s,t,max,min,sum = 0;
				cin >> n;
				if(n == 0)break;
				else{
					cin >> s;
					max = min = sum = s;
					for(int i = 0; i < (n - 1);++i){
						cin >> t;
						if( t > max ){ max = t;}
						if( t < min ){ min = t;}
						sum += t;
					}
					cout << (sum - max - min) / (n - 2) << endl;
				}

	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>
#include<type_traits>
long long int D[400000000];
long long int E[400000000];

using namespace std;
int main() {
	long long int N;
	long long int Y = -1;
	cin >> N;
	while (N) {
		Y++;
		for (long long int i = 0; i < N; i++) {
			cin >> D[i];
		}

		sort(D, D + N);
		long long int W = 0;
		for (long long int i = 1; i < N-1; i++) {
			W += D[i];
		}
		E[Y] = W / (N-2);
		cin >> N;
		
	}

	for (long long int i = 0; i <=Y ;i++) {
		cout << E[i] << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
while(1){
int judge;
int maxscore =0;
int minscore =0;
cin >> judge;
if(judge != 0){
int score[judge];
	for(int i=0; i<judge; i++){
	cin >> score[i];
		if(score[i] > maxscore){
		maxscore = score[i];
		}
		if(score[i] < minscore){
		minscore = score[i];
		}
		if(i==0){
		minscore = score[0];
		}
	}
int lastscore = 0;
for(int j=0;j<judge;j++){
lastscore +=  score[j];
}
lastscore = (lastscore - maxscore - minscore)/(judge - 2);
cout << lastscore <<endl;
}else
break;
}
return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
        int n, s ;
	while (cin >> n && n > 0){
		int large = 0;
		int small = 1000;
		int sum = 0;
  		for (int i=0; i<n; ++i){
			cin >> s;
			sum = sum + s;
			if (large < s) {large = s;}
			if (small > s) {small = s;}
		}
		int ans = 0;
		ans = (sum - large - small) / (n - 2);
		cout << ans << endl ;
	}
}

C++: #include<stdio.h>

void QSort(int x[ ], int left, int right);
void Swap(int x[ ], int i, int j);

void QSort(int x[ ], int left, int right)
{
    int i, j;
    int pivot;

    i = left;                   
    j = right;                  

    pivot = x[(left + right) / 2];
    while (1) {                   

        while (x[i] < pivot)      
            i++;                  

        while (pivot < x[j])      
            j--;                  
        if (i >= j)               
            break;                

        Swap(x, i, j);            
        i++;                      
        j--;
    }

    if (left < i - 1)              
        QSort(x, left, i - 1);     
    if (j + 1 <  right)            
				QSort(x, j + 1, right);    
		}

void Swap(int x[ ], int i, int j)
{
    int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}

int main(void)
{
	int i;
	int j;
	int k;
	int n;
	int d[20];
	int p[100];
	int sum;
	int ave;
	
	while(1){

		scanf("%d",&n);
		if(n==0) 
			break;
		
		j=0;
		for(i=0;i<n;i++){
		scanf("%d",&p[i]);
		}

		QSort(p,0,n-1);	
	
		sum = 0;
		for(i=1;i<n-1;i++)
			sum += p[i];
	
			d[j] = sum / (n-2);
			j++;
	}
	
	for(k=0;k<j;k++){
		printf("%d",d[k]);
	}
	
	return 0;
}

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

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

int main(){

    while(1){
        int n;
        cin >> n;
        if(n == 0){
            break;
        }

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

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

        int sum = accumulate(s.begin(), s.end(), 0);

        sum -= (s[0] + s[n - 1]);

        int ans = sum / (n - 2);
        cout << ans << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int N;
int Point[100];
int High=-1;
int Low=1001;
int main()
{
	while(true){
		scanf("%d",&N);
		if(N==0)break;
		High=-1;Low=1001;
		int sum=0;
		for(int i=0;i<N;i++){
			scanf("%d",&Point[i]);
			sum+=Point[i];
			High=max(Point[i],High);
			Low=min(Point[i],Low);
		}
		printf("%d\n",(sum-High-Low)/(N-2));
	}
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define vsort(v) sort(v.begin(),v.end())
#define asort(a,n) sort(a, a + n)
#define vi vector<int>
#define vd vector<double>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int N;
    int ans;
    int cnt;
    vi vec(100);
    while(true){
        vec.assign(100, -1);
        ans = 0;
        cnt = 0;
        cin >> N;
        if(N == 0) return 0;
        rep(i, N){
            cin >> vec[i];
        }
        vsort(vec);
        REP(i, 101 - N, 99){
            ans += vec[i];
            cnt++;
        }
        cout << (int)(ans / cnt) << endl;
    }


    return 0;
}