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 <iostream>
using namespace std;

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

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

int main(){
	while(1){
		int n, s[100];
		int ans=0;
		
		scanf(" %d", &n);	
		if(n==0) break;
		for(int i=0; i<n; ++i) scanf(" %d", &s[i]);
		sort(s, s+n);
		
		for(int i=1; i<n-1; ++i) ans+=s[i];
		
		printf("%d\n", ans/(n-2));
	}
	return 0;
}

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

int main(int argc, char const *argv[]) {
    vector<int> vc;
    while(true){
        int n;cin>>n;
        if(n==0)break;
        int max,min;
        int sum=0;
        for(int i=0;i<n;i++){
            int score;cin >> score;
            if(i==0){
                min = score;
                max = score;
            }
            if(max < score)max = score;
            if(min > score)min = score;
            sum+=score;
        }
        sum -= max;
        sum -= min;
        int avg = sum/(n-2);
        cout << avg << endl;
    }
    return 0;
}

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

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF (1 << 30)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int main() {
	int N;
	while(scanf("%d", &N), N) {
		int res = 0;
		int maxi = -1, mini = INF;
		int a;
		rep(i, N) {
			scanf("%d", &a);
			res += a;
			maxi = max(maxi, a);
			mini = min(mini, a);
		}
		res = res - (maxi + mini);
		double ans = (double)res / (N - 2) * 10;
		res = (int)(ans / 10);
		printf("%d\n", res);
	}
	return 0;
}

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

int main(){


  int n;

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

    //テ・ツ?・テ・ツ環?
    int point[200];
    for(int i = 0; i < n ; i++){
      cin >> point[i];
      cout << point[i] << " ";
    } 
    cout << endl;

    //max
    int max = -1;
    for(int i = 0 ; i < n ; i++){
      if(point[i] > max)
	max = point[i];
    }
    for(int i = 0 ; i < n ; i++){
      if(point[i] == max){
	point[i] = -1;
	break;
      }
    }

    //min
    int min = 10000;
    for(int i = 0 ; i < n ; i++){
      if(point[i] < min && point[i] != -1 )
	min = point[i];
    }
    for(int i = 0 ; i < n ; i++){
      if(point[i] == min){
	point[i] = -1; 
	break;     
      }
    }

    int ans = 0;
    for(int i = 0; i < n ; i++){
      if(point[i] > -1)
	ans += point[i];
   cout << point[i] << " ";
    }
    ans = ans / (n-2);
    cout << ans << endl;

  }

  return 0;
}

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 <<endl;
	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,s[100],m,M,sum=0;
    cin >> n;
    for(int i=0;i<n;i++)    cin >> s[i];
    for(int i=0;i<n;i++){
        sum+=s[i];
        m=min(m,s[i]);
        M=max(M,s[i]);
    }
    cout << (double)(sum-M-m)/(n-2)<<endl;
    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
using namespace std;

int main(){
	int N,S;
	while(cin>>N,N){
		int sum=0,min_=INT_MAX,max_=INT_MIN;
		for(int i=0;i<N;i++){
			cin>>S;
			min_ = min(min_,S);
			max_ = max(max_,S);
			sum += S;
		}
		printf("\t%d\n",(sum-min_-max_)/(N-2));
	}
	return 0;
}

C++: #include <iostream>

int main()
{
    int n, s = 0;
    while (std::cin >> n && n > 0) {
        int max, min, sum = 0;
        std::cin >> s;
        max = s;
        min = s;
        sum += s;

        for (int i = 0; i < n - 1; i++) {
            std::cin >> s;
            if (s > max)
                max = s;
            if (s < min)
                min = s;
            sum += s;
        }
        std::cout << (sum - max - min) / (n - 2) << '\n';
    }

    return 0;
}

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

int main(){
  int n,s,sum,ma,mi;

  while(cin >> n, n){
    cin >> sum;
    ma = mi = sum;
    for(int i=1;i<n;i++){
      cin >> s;
      sum += s;
      ma = max(ma,s);
      mi = min(mi,s);
    }

    cout << (sum-ma-mi)/(n-2) << endl;
  }
}

C++: #include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<random>
#include<string>
typedef long long ll;
using namespace std;
int main(){
  ll N;
  ll s[1100];
  ll sum=0;
  ll t=0;
  while(t<=20){
  t++;
  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;
}
}

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

using namespace std;

int main(){
    int n;
    while(cin >> n && n){
        int mini = 1 << 29;
        int maxi = -1;
        int sum = 0;
        int tmp;
        for(int i=0;i<n;i++){
            cin >> tmp;
            mini = min(mini, tmp);
            maxi = max(maxi, tmp);
            sum += tmp;
        }
        cout << (sum - mini - maxi) / (n - 2) << endl;
    }
}

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

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

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

using namespace std;

int main(){
	int n;
	while(cin >> n){
		if(n==0) break;
		int m = 9999999, M = 0, sum = 0;
		for(int i=0;i<n;i++){
			int tmp; cin >> tmp;
			m = min(m,tmp);
			M = max(M,tmp);
			sum += tmp;
		}
		cout << ((sum-m-M)/(n-2)) << endl;
	}
}