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<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;
  }
}

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

int main()
{
	int n,m,i;
	int ave[1000]={0};

	m=0;
	while(1){
		int point[100]={0};
		int min=1000;
		int max=0;
		cin>>n;
		if(n==0) break;
		for(i=0;i<n;i++){
			cin>>point[i];
			if(point[i]>max) max=point[i];
			if(point[i]<min) min=point[i];
			ave[m]+=point[i];
		}
//		cout<<"debug "<<ave[m]<<endl;
//		cout<<max<<" "<<min<<endl;
		ave[m]=(ave[m]-max-min)/(n-2);
		m++;
	}
	for(i=0;i<m;i++){
		cout<<ave[i]<<endl;
	}
}

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

// hona method

int main()
{
	while(1)
	{
		int judges;
		int scores[1024];
		int total = 0;

		::scanf("%i", &judges);

		if(judges == 0)
		{	break;	}
		
		for(int j = 0; j < judges; j ++)
		{
			::scanf("%i", &scores[j]);
		}

		std::sort(scores, scores + judges);

		/*for(int j = 0; j < judges; j ++)
		{
			::printf("%i\n", scores[j]);
		}*/
		for(int j = 1; j < judges - 1; j ++)
		{
			total += scores[j];
		}
		printf("%i\n", total / (judges - 2));
	}
}

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

int main(void)
{


  int score[100];
  int sum, avg, i, n,tmp,j, count=0;
  while(1)
    {
      cin>>n;
      score[count]=n;
      count++;
      if(n<=0) {
        count-=1;
        break;
      }
    }
  //input
 for(i=0;i<count; i++){
    for(j=i+1; j<count; j++){
      if(score[i]>score[j]){
        tmp=number[i];
        number[i]=number[j];
        number[j]=tmp;
      }
    }
  }
  //sort
for(i=1; i<count-1; i++)
        {
          sum+=score[i];
          avg=sum/i;
        }
 cout<<avg;

       }
//output
  return 0;

}

C++: #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (typeof((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(typeof(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}



int main() {
    //freopen( "/Users/macuser/Documents/Programming/Contest/input.in", "r", stdin );
    
    int n;
    while (cin >> n) {
        if (n == 0) break;
        vint num(n);
        for (int i = 0; i < n; ++i) cin >> num[i];
        sort(ALL(num));
        
        int sum = 0;
        for (int i = 1; i < n-1; ++i) sum += num[i];
        sum /= (n-2);
        
        cout << sum << endl;
    }
    
    
    return 0;
}

C++: #include <iostream>

using namespace std;

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

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n, data[100];
	while (cin >> n && n) {
		int sum = 0;
		for (int i = 0; i < n; ++i) cin >> data[i];
		sort(data, data + n);
		for (int i = 1; i < n - 1; ++i) sum += data[i];
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1, 0};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    while(true){
        int n;
        cin >> n;
        if(!n) break;
        vector<int> s(n);
        for(int i = 0; i < n; ++i){
            cin >> s[i];
        }
        cout << (accumulate(s.begin(), s.end(), 0) - *max_element(s.begin(), s.end()) - *min_element(s.begin(), s.end())) / (n-2) << "\n";
    }
    return 0;
}