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 <vector>

using namespace std;

int main(){
	vector<int> array;
	int i,x,max,min,sum,n;
	max = 0;
	min = 1000;

	while(cin>>n){
	array.clear();
	sum=0;

	for(i=0;i<n;i++){
		cin >> x;
		array.push_back(x);
	}
	for(i=0;i<n;i++){
		if(max<array[i]){
			max= array[i];
		}
	}
	for(i=0;i<n;i++){
		if(min>array[i]){
			min= array[i];
		}
	}
	for(i=0;i<n;i++){
		sum += array[i];
	}
	sum = sum-max-min;
	cout << sum/n << endl; 
	}

}

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

using namespace std;

int main()
{
    int n;

    while (cin >> n, n) {
        int ans = 0, s;
        int max_s, min_s;

        max_s = 0;
        min_s = 1000;
        for (int i = 0; i < n; i++) {
            cin >> s;

            ans += s;
            max_s = max(max_s, s);
            min_s = min(min_s, s);
        }

        cout << (ans - max_s - min_s) / (n - 2) << endl;
    }

    return 0;
}

C++: #include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
signed main() {
  int N;
  while (cin>>N,N!=0){
    int ma = 0, mi = INF;
    int ans=0;
    for(int i=0;i<N;i++){
      int t;cin>>t;
      ma=max(ma,t);
      mi=min(mi,t);
      ans+=t;
    }
    ans-=ma+mi;
    N-=2;
    ans/=N;
    cout<<ans<<endl;
  }
}

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl;
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// Aliases
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

int main() {
    while(true) {
        int n;
        cin >> n;
        if(n == 0) break;
        int sum = 0, smn = INT_MAX, smx = INT_MIN;
        REP(i, n) {
            int s;
            cin >> s;
            sum += s;
            smn = min(smn, s);
            smx = max(smx, s);
        }
        cout << (sum - smn - smx) / (n - 2) << "\n";
    }

    return 0;
}

C++: #include <iostream>
#include <limits.h>

#define el endl
#define fd fixed

using namespace std;

int main() {
  while (1) {
    int n;
    cin >> n;
    int m = n;
    if (n == 0) break;
    int max = INT_MIN;
    int min = INT_MAX;
    int ave = 0;
    while (m--) {
      int x;
      cin >> x;
      ave += x;
      if (x < min) min = x;
      if (x > max) max = x;
    }
    ave = ave - (max + min);
    ave = ave / (n-2);
    cout << ave << el;
  }
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){

  int sum = 0, x, total, ans;
  vector<int> p(0);
  int n;
  
    while(1){
      cin >> n;
      if(n==0)
      break;
      for(int i=0; i<n; i++){
        cin >> x;
        p.push_back(x);
      }

      int max = *max_element(p.begin(), p.end());
      int min = *min_element(p.begin(), p.end());

      for(int i=0; i<n; i++){
        sum += p[i];
      }
      total = sum - min - max;
      ans = total / (n-2);
      cout << ans << endl;
    }

  return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = 3.141592653589793;
int n;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    while (n!=0) {
        int  s[105]={};
        rep(i,n) cin >> s[i];
        sort(s,s+n);
        int ans=0;
        rep2(i,1,n-1) ans+=s[i];
        cout << ans /(n-2) << endl;
        cin >> n;
    }
    return 0;
}

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

int main(){
  int n,maxn,minn,ave,sum = 0;

  while(cin >> n){
    if(n == 0) break;
    
    int *s = new int[n];

    cin >> s[0];
    maxn = minn = 0;
    for(int i = 1; i<n ; ++i){
      cin >> s[i];

      if(s[maxn]  <= s[i]){
	maxn = i;
      }
      if(s[minn] >= s[i]){
	minn = i;
      }

      
    }

    for(int i=0; i<n ; ++i){
      if(i != maxn && i != minn){
	sum += s[i];
      }
    }


    
    ave = sum/(n - 2);

    cout << ave << endl;

    sum = 0;
    ave = 0;
    
    delete[] s;
  }
  
  
  return 0;
}

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

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()

using namespace std;

typedef vector<int> vi;

int main(){
	int n;
	while(cin >> n, n){
		vi v(n);
		rep(i, n){
			cin >> v[i];
		}
		sort(all(v));
		int sum = 0;
		for(int i = 1; i < n-1; i++){
			sum += v[i];
		}
		cout << sum/(n-2) << endl;
	}

	return 0;
}

C++: #include<stdio.h>

int sum(int x[], int n)
{
  int a, t_sum=0;
  for(a=1; a<n-1; a++)
    {
      t_sum+=x[a];
    }
  return t_sum;
}


int main(void)
{
  int count=0, check=0, i=0,k=0, avg[10]={0};

  while(1)
    {
      int  temp=0, score[100]={0};
      scanf("%d", &count);
      if(count==0)
	{

	  for(i=1;i<=k;i++)
	    {
	      printf("%d\n", avg[i]);
	    }
	  return 0;
	}
      else
	{
	  k++;
	  for(i=0; i<count; i++)
	    {
	      scanf("%d", &check);
	      score[i]=check;
	    }
int t, j, temp;

  for(t=0;t<count-1;t++)
    {
      for(j=count-1;j>t; j--)
	{
	  if(score[j-1]>score[j])
	    {
	    temp=score[j];
	  score[j]=score[j-1];
	  score[j-1]=temp;
	    }
	}
    }
	  temp=sum(score,count);

	  avg[k]=temp/(count-2);
	  
	}
    }

}

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