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<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    while(1){
        int mn=1000000,mx=0;
        int sum=0,a;
        cin>>n;
        if(n==0){break;}
        for(int i=0;i<n;i++){
            cin>>a;
            mx=max(a,mx);
            mn=min(a,mn);
            sum+=a;
        }
        sum-=mx;
        sum-=mn;
        cout<<sum/(n-2)<<endl;
    }
        
    return 0;
    
}

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

int main() {
	int i, n, tmp, sum;
	priority_queue<int> q;
	while (1) {
		cin >> n;
		if (n == 0)break;
		sum = 0;
		for (i = 0; i < n; i++) {
			cin >> tmp;
			q.push(tmp);
		}
		q.pop();
		while (q.size() > 1) {
			sum += q.top();
			q.pop();
		}
		q.pop();
		cout << sum / (n - 2) << endl;
	}





	return 0;
}

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

int main(){

	int n;
	while(cin >> n, n){
		vector<int> score;
		for(int i=0; i<n; i++){
			int s; cin >> s;
			score.push_back(s);
		}
		sort(score.begin(), score.end());
		int sum = accumulate(score.begin(), score.end(),0);
		cout << ( sum - score.back() - score.front() )/ (score.size()-2) << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
  int n;
  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);
    if(n >= 3){
      for(int i = 1 ; i < n - 1 ; i++){
	average += point[i];
      }
    }
    if(n >= 3) average /= (n-2);
    cout << average << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

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

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

int N, S;

int main()
{
   while ( cin >> N && N>0)
   {
      int 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;
}

C++: #include <iostream>

using namespace std;

#define min(a, b) ((a)<(b)? (a):(b))
#define max(a, b) ((a)>(b)? (a):(b))

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

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

void totalize(int n)
{
    int min = 1000, max = 0;
    int s, total = 0;
    for (int i = 0; i < n; i++) {
        cin >> s;
        total += s;
        if (s < min) {
            min = s;
        } else if (max < s) {
            max = s;
        }
    }
    cout << (total - max - min) / (n - 2) << endl;
}

int main()
{
    int n;
    while (true) {
        cin >> n;
        if (n == 0) {
            break;
        }
        totalize(n);
    }
}

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

int main(){
  while(1){
  int n;
  cin >> n;
  if(n==0) break;
  vector<int> a;
  int tmp=0;
  for(int i=0;i<n;i++) {
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(),a.end());
  int ave=0;
  for(int i=1;i<n-1;i++){
    ave+=a[i];
  }
  ave=ave/(n-2);

  cout << ave << endl;
  }
  return 0;

}

C++: #include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <ctime>
#include <iterator>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int main()
{
    int n;
    while(cin>>n)
    {
        int sum = 0;
        int mini = 10000000;
        int maxi = 0;
        for(int c=0;c<n;c++)
        {
            int z;
            cin>>z;
            mini = min(mini,z);
            maxi = max(maxi,z);
            sum += z;
        }
        cout<<(sum-mini-maxi)/(n-2)<<endl;
    }
}

C++: #include<iostream>
using namespace std;
int main(){
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;
}
return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    register int n,i;
    while(cin >> n,n){
		register int p;
        register int min = 1000;
        register int max = 0;
		register int total = 0;
		for(int i=0;i<n;i++){
			cin >> p;
			if(p > max) max = p;
			if(p < min) min = p;
			total += p;
        }
        cout << (total-max-min)/(n-2) << "\n";
    }
}

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

int main(){
	while(1){
		int n,score=0;
		std::cin>>n;
		if(n==0)break;
		std::vector<int>v(n);
		for(int i=0;i<n;i++)std::cin>>v[i];
		for(int i=0;i<n;i++){
			for(int j=0;j<n-1;j++){
				if(v[j]>v[j+1]){
					v[j]^=v[j+1];
					v[j+1]^=v[j];
					v[j]^=v[j+1];
				}
			}
		}
		for(int i=1;i<n-1;i++)score+=v[i];
		std::cout<<score/(n-2)<<std::endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    while(N){
        int sum = 0,a,maxi = 0,mini = INF;
        rep(i,0,N){
            cin >> a;
            sum += a;
            maxi = max(maxi, a);
            mini = min(mini, a);
        }
        sum -= (maxi + mini);
        cout << sum / (N - 2) << endl;
        cin >> N;
    }
}

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

using namespace std;

void find_max(int data[], int N){
  int flag = -1;
  int max = 0;
  for (int i=0; i<N; ++i){
    if (max < data[i]){
      max = data[i];
      flag = i;
    }
  }
  data[flag] = 0;
}

void find_min(int data[], int N){
  int flag = -1;
  int min = 1000000;
  for (int i=0; i<N; ++i){
    if (min > data[i]){
      min = data[i];
      flag = i;
    }
  }
  data[flag] = 0;
}

int main(void){
  int n;
  while (cin >> n){
    if (n == 0){
      return -1;
    }
    
    int data[20];
    
    for (int i=0; i<n; ++i){
      cin >> data[i];
    }
    cout << "finish" << endl;
    find_min(data, n);
    find_max(data, n);
    int sum = 0;
    for (int i=0; i<n; ++i){
      sum += data[i];
    }
    int total = floor((double)sum/(n-2));
    cout << total << endl;
  }
  return 0;
}

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

int main()
{
  int n;
  while(cin >> n, n){
    vector<int> s(n);
    for(int i = 0; i < n; i++) cin >> s[i];
    sort(s.begin(), s.end());

    int sum = 0;
    int i;
    for(i = 1; i < n - 1; i++) sum += s[i];
    cout << sum / (i - 1) << endl;
  }

    return 0;

}