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())
		if n == 0 {
			break
		}
		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 < len(scores)-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

C++: #include <stdio.h>
#include <stdlib.h>

int main(){
    
    // 各種変数宣言
    
    int n,x,y,i,j,k,c,a,p=0;
    int min,max,answer,carda[100];
    // 配列宣言
    
    
    // メインループ
    
    while(1){
        int card[500]={};
        
        // nとpを読み込む
        scanf("%d", &n);
        if(n==0)break;
        
        for(i=0;i<n;i++){
        scanf("%d", &card[i]);
        }
        
        min=1001;
        for(i=0;i<n;i++){
            if(min>card[i] || min==card[i]){
                min=card[i];
                x=i;
            }
        }
        
        max=0;
        for(i=0;i<n;i++){
            if(max<card[i] || max==card[i]){
                max=card[i];
                y=i;
            }
        }
        
        
        card[x]=0;
        card[y]=0;
        k=0;
        for(i=0;i<n;i++){
            k+=card[i];
        }
        
        answer=k/(n-2);
        carda[p]=answer;
        p++;
    }
    for(i=0;i<p;i++){
        printf("%d\n",carda[i]);
    }
    // 終了
    return 0;
    
}

C++: #include<iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <math.h>
//1147
using namespace std;
int a,b,maxa=0,mina=10000,tot=0;
double ans;
	int main(){
		while(cin>>a){
			if(a==0){
			break;}
			for(int i=0;i<a;i++){
			cin>>b;
			tot+=b;
			if(maxa<b){maxa=b;}
			if(mina>b){mina=b;}}
			ans=(tot-maxa-mina)/(a-2);
		cout<<floor(ans)<<endl;
		tot=0;mina=10000;maxa=0;}
		return 0;}

C++: #include<iostream>
using namespace std;
int main(){
	int n,x,max,min,pre;
	while(cin>>n,n){
		cin>>x;
		pre=x;
		max=x;
		min=x;
		for(int i=0;i<n-1;i++){
			cin>>x;
			pre+=x;
			if(max<x)
				max=x;
			if(min>x)
				min=x;
		}
		cout<<(pre-max-min)/(n-2)<<endl;
		
		
		
		
	}
	return 0;
}

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

int main(){
	int S[1005];
	int n,sum;
	while(1){
		cin>>n;
		if(n==0) break;
		sum=0;
		for(int i=0;i<n;i++) cin>>S[i];
		sort(S,S+n);
		for(int i=1;i<n-1;i++) sum+=S[i];
		cout<<sum/(n-2)<<endl;
	}
	return 0;
}

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

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

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define rrep(i,n) for(int i = n - 1; i >= 0; i--)
#define REP(i,k,n) for(int i = k; i < n; i++)

#define vi vector<int>
#define pb push_back
using namespace std;
typedef long long ll;

int main(){
    int n;
    while(cin >> n,n) {
        vi a;
        int tmp;
        rep(i,n){
            cin >> tmp;
            a.pb(tmp);
        }
        sort(a.begin(),a.end());
        ll sum = 0;
        REP(i,1,n - 1){
            sum += a[i];
        }
        cout << sum / (n - 2) << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	while(true){
		int score;
		int n;
		int maxs,mins;
		cin>>n;
		if(n==0)break;
		vector<int> s(n);
		for(int i=0;i<n;i++){
			cin>>s[i];
		}
		maxs=*max_element(s.begin(),s.end());
		mins=*min_element(s.begin(),s.end());
		for(int i=0;i<n;i++){
			score+=s[i];
		}
		cout<<(score-maxs-mins)/(n-2)<<endl;
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <iomanip>
#include <functional>
using namespace std;
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

int main(int argc, char* argv[])
{
	

	while(1){
		double ans=0;
		int i=0;
		int a;
		int ninzu;
		vector <int>  s;

		cin >> ninzu;

		for(i=0;i<ninzu;i++){
			cin >> a;
			if(a == 0)break;
			s.push_back(a);
			
			
		}
		sort( ALL(s) );

		for(i=1;i<s.size()-1;i++){
			if(s[i] != 0)ans+= s[i];
		}

		ans = ans / (i-1);

		cout << fixed << setprecision(0) << ans << endl;
		ans=0;

	}

    return 0;
}

C++: #include <iostream>
using namespace std;
int N, S;

int main()
{
    while ( cin >> N and N > 0) {
        int sum = 0;
        int largest = 0;
        int smallest = 1000;
        for (int i = 0; i < N; i++) {
            cin >> S;
            sum += S;
            if ( S > largest ) largest = S;
            if ( S < smallest ) smallest = S;
        }
        sum = sum - largest - smallest;
        int ave = sum / (N - 2);
        cout << ave << endl;
    }
    return 0;
}

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

int  main(){
  int n,s,sum=0,avg;
  vector<int>a;

  
  while(cin>>n,n){
    sum=0;
    avg=0;
    a.clear();
  for(int i=0;i<n;i++){
    cin>>s;
    a.push_back(s);
  }
 
  sort(a.begin(),a.end());
  
  for(int i=1;i<n-1;i++){
    sum=sum+a.at(i);
  }
    avg=sum/(n-2);
    
    cout<<avg<<endl;

  }



}

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

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

using namespace std;

int n;
int s[102];
void solve() {
    int mini = 10000;
    int maxi = -1;
    int ans = 0;
    rep(i, n) {
        if (s[i] < mini) mini = s[i];
        if (s[i] > maxi) maxi = s[i];
        ans += s[i];
    }
    ans -= mini;
    ans -= maxi;

    printf("%d\n", ans / (n - 2));
}

int main() {
    while (cin >> n) {
        if (n == 0) break;
        rep(i, n) cin >> s[i];
        solve();
    }
}

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


int main(void){
  while(1){
    int n;
    std::vector<signed int> s;
    std::vector<signed int>::iterator it;

    std::cin >> n;
    if(n == 0) return 0;
    for(int i=0; i < n; i++){
      int inputting;
      std::cin >> inputting;
      s.push_back(inputting);
    }


    int max = -1, min = 1001;
    std::vector<int>::iterator maxind, minind;
    for(it = s.begin(); it != s.end(); it++){
      if(*it > max){
        max = *it;
        maxind = it;
      }
      if(*it < min){
        if(*it == 0)  min = 0;
        else{
        min = *it;
        minind = it;
        }
      }
    }

    s.erase(maxind);
    s.erase(minind);
    int sum = 0, avr;
    for(it = s.begin(); it != s.end(); it++){
      sum += *it;
    }
    std::cout << sum / s.size() << std::endl;
  }
}

C++: 
#include<cstdio>
#include<iostream>
#include<string>
#include <algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
using namespace std;
using ll = long long;



int main(){
	int n, s[100];
	int k = 0;
	while (1){
		cin >> n;
		if (n == 0) break;
		for (int i = 0; i < n; i++) cin >> s[i];
		sort(s, s + n);
		for (int i = 1; i < n - 1; i++) {
			k += s[i];
		}
		cout << k / (n-2) << endl;
	}

}