Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for {
		num := nextInt(sc)
		if num == 0 {
			break
		}

		score_list := []int{}
		for i := 0; i < num; i++ {
			score_list = append(score_list, nextInt(sc))
		}
		// 得点リストをソートした後、最低点と最高点を取り除く(3 ≤ n ≤ 100)
		sort.Sort(sort.IntSlice(score_list))
		score_list = score_list[1 : len(score_list)-1]
		// 得点リストの得点を合計し、スライスの個数で割って平均点を出す
		sum := 0
		for _, score := range score_list {
			sum += score
		}
		fmt.Println(sum / len(score_list))
	}
}

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

int main(){
  while (1){
    int n,p,sum=0;
    cin >> n;
    if (n==0) return 0;
    vector<int> points;
    for(int i=0;i<n;i++){
      cin >> p;
      points.push_back(p);
    }
    sort(points.begin(),points.end());
    points.erase(points.begin());
    points.pop_back();
    for (int i=0;i<points.size();i++){
      sum+=points[i];
    }
    cout << floor(sum/points.size()) << endl;
  }
}

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

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

C++: #include<iostream>
typedef long long ll;
using namespace std;
int main(){
  ll N;
  ll s[1100];
  ll sum=0;
  ll t=1;
  while(N){
  cin >>N;
  for(ll i = 0; i < N; ++i){
      cin >> s[i];
  }
  sort(s,s+N);
  for(ll i = 1; i < N-1; ++i){
    sum+=s[i];
  }
  cout<<sum/(N-2)<<endl;
  cin>>N;
}
}

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

int main(){
	int n, s, sum, max, min, i;
	while((cin >> n), n){
		sum = max = 0;
		min = 1000;
		for(i = 0; i < n; i++){
			cin >> s;
			sum += s;
			max = max(max, s);
			min = min(min, s);
		}
		cout << (int)(sum / n) << endl;
	}
}

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

int n, sum, l, s;

int main() {
  
  int a;
  while(cin>>n,n) {
    cin>>a;
    sum = a;
    l = a;
    s = a;
    for(int i=1;i<n;i++) {
      cin>>a;
      if(a>l)l=a;
      else if(a<s)s=a;
      sum+=a;
    }
    sum -= l+s;
    sum = sum/(n-2);
    cout<<sum<<endl;
  }
  
  return 0;
}

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


}

C++: #include <stdio.h>
 
int main() {
 
  int n,a[100] = {0};
  int i,j,k,l;
  int sum;
  int suma[30];
  j = 0;
  while(1) {
 int max = -1;
  int min = 10001;
   sum = 0;
 
  scanf("%d",&n);
  if(n == 0){
    break ;}
 
  for(i=0;i<n;i++) {
 
    scanf("%d",&a[i]);
    sum = sum + a[i];
    if(min > a[i] ) {
      min = a[i];
    } if( max < a[i]) {
      max  = a[i];
    }
  } 
 sum = (sum-max-min) / (n-2);
 suma[j] = sum;
 j++;
 
  }
 
  //  printf("sum = %d\n",sum);
  // printf("max = %d min = %d",max,min);
 
  for(i = 0; i < j; i++) {
 
  printf("%d\n",suma[i]);
   
  }
 
  return 0;
 
}

C++: #include<iostream>
using namespace std;
int main(){
    int n,i;
    while(cin >> n,n){
		int p;
        int min = 1000;
        int max = 0;
		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 <algorithm>
#include <numeric>
using namespace std;

int a[10];
int n;
int s[100];
int s_max, s_min;
int sum = 0;
int ave = 0;

int main() {
  while(cin >> n, n)
  {
  for(int i =0; i < n; i++){
    cin >> s[i];
  }
  
  s_max = *max_element(s, s + n);
  s_min = *min_element(s, s + n);

  sum = accumulate(s, s + n, 0);

  sum = sum - s_max - s_min;

  ave = sum/(n-2);
  cout << ave << endl;
  }
  return 0;
}

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

int main() {
	int n;
	while(cin >> n, n != 0) {
		vector<int> v(n);
		for(int i = 0; i < n; ++i) {
			cin >> v[i];
		}
		
		sort(v.begin(), v.end());
		
		int ans = 0;
		
		for(int i = 1; i < n - 1; ++i) {
			ans += v[i];
		}
		
		cout << ans / (n - 2) << endl;
	}
	return 0;
}

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

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

int n,s;

int main(){
    while(cin>>n&&n){
	int sum=0,M=0,m=1000;
	rep(i,n){cin>>s;sum+=s;if(s>M)M=s;if(s<m)m=s;}
	cout<<(sum-M-m)/(n-2)<<endl;
    }
}

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

int main(){
	int n;
	while(cin >>n){
		if(n == 0) break;
		vector<int> vec;
		int tmp, max, min;
		cin >>tmp;
		vec.push_back(tmp);
		max = tmp;
		min = tmp;
		bool maxb = true, minb = true;
		for(int i = 1; i < n; i++){
			cin >>tmp;
			vec.push_back(tmp);
			if(tmp < max) max = tmp;
			if(tmp > min) min = tmp;
		}
		int sum = 0;
		for(int i = 0; i < vec.size(); i++){
			if(vec[i] == max && maxb){
				maxb = false;
			} else if(vec[i] == min && minb){
				minb =false;
			} else{
				vec[i] += sum;
			}
		}
		cout <<(sum / (n - 2)) <<endl;
		return 0;
	}
}

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

using namespace std;

int main() {

	int N, shortest, largest, sum, tmp;

	while (true) {
		cin >> N;
		if (N == 0)
			break;

		sum = 0;
		shortest = 10000;
		largest = -1000;

		for (int i = 0; i < N; i++) {
			cin >> tmp;
			sum += tmp;
			shortest = min(shortest, tmp);
			largest = max(largest, tmp);
		}

		sum -= shortest;
		sum -= largest;

		cout << sum / (N - 2) << endl;

	}

	return 0;
}

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

int n, sum, l, s;

int main() {
  
  int a;
  while(cin>>n,n) {
    cin>>a;
    sum = a;
    l = a;
    s = a;
    for(int i=1;i<n;i++) {
      cin>>a;
      if(a>l)l=a;
      else if(a<s)s=a;
      sum+=a;
    }
    sum = sum/(n-2);
    cout<<sum<<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;
      if(min > s) min = s;
    }
    sum -= max;
    sum -= min;
    int ave = sum / (n-2);

    cout << ave << endl;
  }

  return 0;
}

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

int main(){
	int n;
	while(std::cin >> n, n){
		std::vector<int> v;
		for(int i=0;i<n;i++){
			int j;
			std::cin >> j;
			v.push_back(j);
		}
		std::sort(v.begin(), v.end());
		int ave = 0;
		for(int i=1;i<v.size()-1;i++){
			ave += v[i];
		}
		ave /= n-2;
		std::cout << ave << std::endl;
	}
}

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

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    double h=-1,l=1<<30,sum=0;
    for(int i=0;i<n;i++){
      double s;
      cin>>s;
      sum+=s;
      h=max(s,h);
      l=min(s,l);
    }
    cout<<int((sum-h-l)/(n-2))<<endl;
  }
  return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;

int main(){
        int n;
        while(cin>>n&&n){
                ll ans=0;
                vector<int>s(n);
                for(int i=0;i<n;i++){
                        cin>>s[i];
                        ans+=s[i];
                }
                sort(s.begin(),s.end());
                ans=ans-s[0]-s[n-1];
                cout<<ans/(n-2)<<endl;
        }
        return 0;
}