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 <iostream>
#include <algorithm>
using namespace std;
int main() {
    int n;
    int a[100];
    cin>>n;
    while(n!=0){
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        sort(a,a+n);
        int sum;
        for(int i=1;i<n-1;i++){
            sum+=a[i];
        }
        cout<<sum/(n-2)<<endl;
        cin>>n;
    }
}

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

int main(){
	int n;
	while(1){
		int sum, result;
		cin >> n;
		if(n == 0){
			break;
		}
		vector<int> score;
		for(int i = 0; i < n; i++){
			int s;
			cin >> s;
			score.push_back(s);
		}
		sort(score.begin(), score.end());
		sum = accumulate(score.begin(), score.end(), 0);
		result = (sum - score[0] - score[n-1]) / (n-2);
		cout << result << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;



int main() {
	cout << fixed << setprecision(18);
	long long int n,x[120]={},mymin=INF,mymax=-INF,sum=0;
	cin>>n;
	while(n!=0){
		mymin=INF;mymax=-INF,sum=0;
		for(int i=0;i<n;i++){
			cin>>x[i];
			mymin=min(mymin,x[i]);
			mymax=max(mymax,x[i]);
			sum+=x[i];
		}
		cout<<(sum-mymax-mymin)/(n-2)<<endl;
		cin>>n;
	}
}

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

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

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

		sort(a.begin(),a.end());
		for (int i = 1; i < n-1; i++) sum += a[i];
		cout << sum / (n-2) << endl;

	}
}

C++: 
#include<cstdio>
#include<iostream>
#include<string>
#include <algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
using namespace std;
using ll = long long;



int main(){
	int n, s[100];
	int k = 0;
	while (1){
		cin >> n;
		if (n == 0) break;
		for (int i = 0; i < n; i++) cin >> s[i];
		sort(s, s + n);
		for (int i = 1; i < n - 1; i++) {
			k += s[i];
		}
		cout << k / (n-2) << endl;
	}

}

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

using namespace std;

int main() {
  int n;
  while (cin >> n && n) {
    vector<int> s;
    for (int i = 0; i < n; i++) {
      int tmp;
      cin >> tmp;
      s.push_back(tmp);
    }
    sort(s.begin(), s.end());
    int ans = accumulate(s.begin() + 1, s.end() - 1, 0) / (n - 2);
    cout << ans << 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];
    sum+=v[i];
  }
  cout << (sum-max(v[0],v[n-1])-min(v[0],v[n-1]))/(n-2) << endl;
  }
  return 0;
}

C++: # coding: utf-8

import sys

if __name__ == '__main__':
    while 1:
        n = int(input())
        if n == 0:
            break
        a = [int(input()) for i in range(n)]
        print((sum(a) - min(a) - max(a)) // (n-2));

C++: #include <iostream>
using namespace std;
int main(){
  int a[2020];
  int x,i = 0;
  while (cin >> x){
    a[i++] = x;
  }
  void saiten(int* a,int b);
  saiten(a,0);
}
void saiten(int* a,int j){
  int max = 0, min = 0, ave = 0;
  if (a[j] != 0){
    for (int k = j+1; k <= j+a[j]; k++){
      if (max < a[k])
	max = a[k];
      if (min > a[k])
	min = a[k];
      ave += a[k];
    }
    ave = (ave - max - min)/(a[j]-2);
    cout << ave << endl;
    saiten(a, j+a[j]+1);
  }
}

C++: #include <iostream>
using namespace std;
int max(int a, int b) {
	if (b < a) {
		b = a;
	}
	return b;
}
int min(int a, int b) {
	if (b > a) {
		b=a;
	}
	return b;
}
int main() {
	int s, n, t, sum=0, ave, maxi=0, mini=1000;
	while (1) {
		cin >> n;
		if (n == 0)break;
		for (t = 0; t < n; t++) {
			cin >> s;
			sum = sum + s;
			maxi = max(s,maxi);
			mini = min(s,mini);
		}
		sum = sum - maxi - mini;
		ave = sum / (n-2);
		cout << ave << endl;
		maxi = max(0,0), mini = min(1000,1000),sum=0;
	}
	return 0;
}

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

using namespace std;

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

    }


}

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

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;

    while (cin>>n && n>0){
        vector<int> s;

        for (int i=0;i<n;i++){
            int tmp;

            cin>>tmp;
            s.push_back(tmp);
        }
        sort(s.begin(),s.end());
        cout<<accumulate(++s.begin(),--s.end(),0)/(n-2)<<endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> res;
    while(1){
        int n;
        deque<int> rec;
        cin >> n;
        if(n == 0) break;
        for(int i=0;i<n;i++){
            int tmp;
            cin >> tmp;
            rec.push_back(tmp);
        }
        sort(rec.begin(), rec.end());
        rec.pop_front();
        rec.pop_back();
        int ans = 0;
        for(int i=0;i<n-2;i++){
            ans += rec[i];
        }
        res.push_back(ans/(n-2));
    }
    for(int i=0;i<res.size();i++) cout << res[i] << endl;
    return 0;
}

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

int main() {
int n;
while(cin>>n){
	if(n==0){
		break;
	}
	int sum=0,max=0,min=1000,score;
	for(int k=0;k<n;k++){
		cin>>score;
		sum=sum+score;
		if(score>max){
			max=score;
		}
		if(score<min){
			min=score;
		}
	}
	cout<<(sum-max-min)/(n-2)<<endl;
}
	return 0;
}

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

int main(){
	while(1){
		int n, s[100];
		int ans=0;
		
		scanf(" %d", &n);	
		if(n==0) break;
		for(int i=0; i<n; ++i) scanf(" %d", &s[i]);
		sort(s, s+n);
		
		for(int i=1; i<n-1; ++i) ans+=s[i];
		
		printf("%d\n", ans/(n-2));
	}
	return 0;
}

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

int main(int argc, char const *argv[]) {
    vector<int> vc;
    while(true){
        int n;cin>>n;
        if(n==0)break;
        int max,min;
        int sum=0;
        for(int i=0;i<n;i++){
            int score;cin >> score;
            if(i==0){
                min = score;
                max = score;
            }
            if(max < score)max = score;
            if(min > score)min = score;
            sum+=score;
        }
        sum -= max;
        sum -= min;
        int avg = sum/(n-2);
        cout << avg << endl;
    }
    return 0;
}