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++: #define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

int A[101];

int main()
{
	int n; 
	while(1) {
		cin >> n;
		if (!n) break;
		int minx = inf, maxx = 0, sum = 0;
		rep(i,0,n) {
			int t;
			cin >> t;
			minx = min(minx, t);
			maxx = max(maxx, t);
			sum += t;
		}
		sum -= minx + maxx;
		int ans = floor((double)sum / (n-2));
		cout << ans << endl;
	}

 	return 0;
}

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];
    memset(data, 0, sizeof(data));
    
    for (int i=0; i<n; ++i){
      cin >> data[i];
    }
    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>
using namespace std;

int main(){
  int n, s, sum, max, min;
  while(1){
    cin >> n;
    if(n == 0) break;
    sum = 0;
    cin >> s;
    sum += s;
    max = s;
    cin >> s;
    sum += s;
    if(max < s){
      max = s;
    }else{
      min = s;
    }
    for(int i = 2; i < n; i++){
      cin >> s;
      sum += s;
      if(max < s){
	max = s;
      }else if(min > s){
	min = s;
      }
    }
    sum -= max;
    sum -= min;
    int ave = sum / (n-2);

    cout << ave << endl;
  }

  return 0;
}

C++: #include <stdio.h>
int main(){
  int n,s,i,min=1000,max=3,sum=0,ave;
  while(1){
    scanf("%d",&n);
    if(n==0){
      break;
    }
    for(i=0;i<n;i++){
      scanf("%d",&s);
      if(s<min){
    min=s;
      } 
      if(s>max){
    max=s;
      }
      sum=sum+s;
    }
    sum=sum-max-min;
    ave=sum/(n-2);
    printf("%d\n",ave);
    sum=0;
    min=1000;
    max=3;
  }
  return 0;
}

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

C++: #include<stdio.h>


int n;
int score[110];
int _max,_min;
int i;
int sum;
int ans; 

int main()
{
	
	for(;;)
	{
		_max = 0;
		_min = 100000;
		sum = 0;
		
		scanf("%d",&n);
		if(n == 0)break;
		
		for(i = 0;i < n;i++)
		{
			scanf("%d",&score[i]);
			if(score[i] < _min)
			{
				_min = score[i];
			}
			if(score[i] > _max)
			{
				_max = score[i];
			}
			sum += score[i];
			
		}
		
		ans =( sum - _max - _min) /(n - 2);
		
		printf("%d\n",ans);
		
	}
	
	return 0;
	
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
  int n;
  while(cin>>n,n!=0){
    vector<int> score(n);
    rep(i,n)cin>>score[i];

    vector<int>::iterator minIt = min_element(score.begin(),score.end());
    int minIndex = distance(score.begin(),minIt);
    score.erase(score.begin()+minIndex-1);

    vector<int>::iterator maxIt = max_element(score.begin(),score.end());
    int maxIndex = distance(score.begin(),maxIt);
    score.erase(score.begin()+maxIndex-1);

    int sum = accumulate(score.begin(),score.end(),0);
    cout << sum/score.size() << endl;
  }
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    while(n != 0){
        vector < int > s(n);
        int min = 1001;
        int max = -1;
        int total = 0;
        for(int i = 0 ; i < n ; i++){
            cin >> s[i];
            if(s[i] < min){
                min = s[i];
            }
            if(s[i] > max){
                max = s[i];
            }
            total += s[i];
       }

       cout << (total-min-max)/(n-2) << endl;
       cin >> n;
    }
}

C++: 	max=s;
      }
      else if(min>s){
	min=s;
      }
    }
    cout<<(count-max-min)/(n-2)<<endl;
    count=0;
  }
}

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

using namespace std;

int main(void){
	while(1){
		int n; cin >> n;
		if(!n) break;

		int smin= 9999, smax=-1, sum = 0;
		for(int i=0; i<n; i++){
			int tmp;
			cin >> tmp;
			sum += tmp;
			smin = min(smin, tmp);
			smax = max(smax, tmp);
		}

		cout << (sum - smin - smax) /(n-2) << endl;


	}
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)


int main() {
	cin.sync_with_stdio(false);
	vector<int>ans;
	while (1) {
		int n;
		int p[100];
		int p_min = 1000;
		int p_max = 0;
		int sum = 0;
		cin >> n;
		if (n == 0) {
			break;
		}
		rep(i, n) {
			cin >> p[i];
			p_min = min(p_min, p[i]);
			p_max = max(p_max, p[i]);
			sum += p[i];
		}
		sum = sum - p_min - p_max;
		sum /= (n - 2);
		ans.push_back(sum);
	}
	rep(i, ans.size()) {
		cout << ans[i] << endl;
	}

	return 0;
}

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 = 1000, ave = 0;  #minは大きいところから
  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>
#include <vector>
#include <algorithm>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<int> Vec(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> Vec[i];
		}
		sort(Vec.begin(), Vec.end());
		int sum = 0;
		for(int i = 1; i < n - 1; ++i)
		{
			sum += Vec[i];
		}
		cout << sum / (n - 2) << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

int main() {
	int n;
	while(cin >> n, n) {
		int a = 1001;
		int b = -1;
		int sum = 0;
		for(int i = 0; i < n; ++i) {
			int t;
			cin >> t;
			sum += t;
			a = min(a, t);
			b = max(b, t);
		}
		
		sum -= a + b;
		
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

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

	while(cin>>n){
		int s=0;
		if(n!=0){
			vector<int> a(n);
			for(int i=0;i<n;i++)
				cin>>a[i];
			sort(a.begin(),a.end());
			a[0]=0;
			a[n-1]=0;
			for(int i=0;i<n;i++)
				s+=a[i];
			cout<<s/(n-2)<<endl;
		}
		else
			break;
	}
	
}