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

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

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

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

int main() {
    int i, j=0, n, p[200][200];
    while(cin >> n && n){
        for(i=0; i<n; i++) cin >> p[j][i];
        sort(p[j], p[j]+n);
        cout << accumulate(p[j]+1, p[j]+n-1, 0) / (n-2) << endl;
        j++;
    }
}

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

using namespace std;

#define ll long long

ll MIN(ll num1,ll num2){
    return num1<num2?num1:num2;
}

int main(){

    while(1){
        int N;
        vector<int> V;
        cin>>N;
        if(N==0)break;
        for(int i=0;i<N;i++){
            int v;
            cin>>v;
            V.push_back(v);
        }
        sort(V.begin(),V.end());
        int sum=0;
        for(int i=1;i<N-1;i++)sum+=V[i];
        cout<<sum/(N-2)<<endl;
    }

    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

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

        vector<int> vec(n);
        rep(i, n) cin >> vec[i];

        int ans = accumulate(all(vec), 0);
        sort(all(vec));
        ans -= vec.front();
        ans -= vec.back();

        ans /= n-2;
        cout << ans << endl;
    }
}

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

int N, S;

int main(){
   while ( cin >> N && N>0){
      int M, m, addup;
      M = -1;
      m = 1001;
      addup = 0;
      for ( i = 0; i<N; i++){
         cin >> S;
         addup += S;
         if ( S > M) M = S;
         if ( S < m) m = S;
      }
   cout << (addup - M - m)/(n-2)  << endl;
   }
}