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 <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;


int main() {
  int n;

  while (cin >> n) {
    if (!n) break;

    vector<int> scr(n);
    for (int i=0; i<n; i++) {
      cin >> scr[i];
    }

    int  sum = 0;
    int _max = scr[0];
    int _min = scr[0];

    for (int s : scr) {
      sum  += s;
      _min = min(_min, s);
      _max = max(_max, s);
    }

    sum -= _max;
    sum -= _min;

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

  return 0;
}

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

int main() {
	int a[100];
	int n, s, i, j, sum;

	scanf("%d",&n);

	while(true) {
		sum = 0;
		if(n == 0)break;
		for(i = 0; i < 100; i++) {
			a[i] = 1000;
		}	
		for(i = 0; i < n; i++) {
			scanf("%d",&s);
			a[i] = s;
		}
		std::sort(a,a+100);
		for(j = 1; j < n-1; j++) {
			sum = sum + a[j];
		}
		printf("%d\n",sum/(n-2));
		scanf("%d",&n);
	}
	return 0;
}

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

int main(){
        int i = 0;
        
        while(cin >> i && !(i == 0)){
                int a[i];
                int j = 0;              

                for(j=0; j<i; j++){
                        cin >> a[j];
                }
                cout << endl;           
        
                //sum
                int sum = 0;
                for (j=0; j<i; j++) {
                        sum += a[j];
                }
        
                //largest,smallest
                int largest = 0;
                int smallest = 1000;
                for (j=0; j<i; j++){
                        if (a[j] > largest)
                                largest = a[j];
                        else if (a[j] < smallest)
                                smallest = a[j];
                }
                
                //average
                int average = 0;
                average = (sum - largest - smallest) / (i - 2);
                cout << average;
        }

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

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

int main()
{
	int n;

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

		std::vector<int> v(n,0);

		for ( int i = 0; i < n; ++i ) {
			std::cin >> v[i];
		}

		std::sort(v.begin(), v.end());

		int sum = 0;
		for ( int i = 1; i < n-1; ++i ) {
			sum += v[i];
		}
		std::cout << sum / (n-2) << std::endl;
	}
	return 0;
}

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

int main(){
    int n,s,avg;
    while (cin>>n && n!=0){
        int sum=0,ma=0,mi=1000;
        for (int i=0;i<n;i++){
            cin>>s;
            sum+=s;
            ma=max(ma,s); //最大値の更新
            mi=min(mi,s); //最小値の更新
        }
        avg=(sum-ma-mi)/(n-2); //平均の計算
        cout<<avg<<endl;
    }
}

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

using namespace std;

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

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)

const int LLINF = 1LL << 60;


signed main()
{
  int N;

  while(cin >> N, N) {
    int maxv = -LLINF, minv = LLINF;
    int sum = 0, A;
    Rep(i, N) {
      cin >> A; sum += A;
      maxv = max(maxv, A), minv = min(minv, A);
    }

    sum -= maxv + minv;

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

  return 0;
}

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

int main(){
	int n;
	int j[110];
	int max,min;
	for(;cin>>n,n!=0;){
		for(int i=0;i<n;i++){
			cin>>j[i];
		}
		max=min=0;
		int sum=0;
		for(int i=0;i<n;i++){
			if(max<j[i])max=j[i];
			if(min>j[i])min=j[i];
			sum+=j[i];
		}
		sum-=max+min;
		cout<<sum/(n-2)<<endl;
	}
	return 0;
}

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

using namespace std;

int main(){
	int N, S;
	while(cin >> N && N>0){
		int largest = 0;
		int smallest = 1001;
		int sum = 0;
		for (int i = 0;i<N;i++){
			cin >> S;
			largest = max(largest,S);
			smallest = min(smallest,S);
			sum += S;
		}
		sum = sum - largest;
		sum = sum - smallest;
		cout << sum /(N-2) << endl;
	}
	return 0;
}

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

using namespace std;

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

vector<int> x;

void init(){
  x.clear();
}
bool input(){
  int n;
  cin>>n;
  if(n==0)return false; 
 rep(i,n){
    int a;
    cin>>a;
    x.push_back(a);
  }
  return true;
}

int solve(){
  sort(x.begin(),x.end());
  int sum = 0;
  reps(i,1,x.size()-1)sum+=x[i];
  return sum/(x.size()-2);
}
int main(){
  while(init(),input()){
    printf("%d\n",solve());
  }
}

C++: #include<bits/stdc++.h>
using namespace std;
const int INF = (1<<30);

int main()
{
  int n;
  while( cin >> n, n ) {
    int ma = 0, mi = INF, sum = 0, data;

    for(int i=0; i<n; i++) {
      cin >> data;
      sum += data;
      if( data > ma ) ma = data;
      if( data < mi ) mi = data;
    }
    
    sum = sum - ma - mi;
    cout << sum / (n-2) << endl;
  }

}

C++: #include <iostream>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int main()
{
	int n;
	while(cin >> n,n){
		int s[100];

		for(int i = 0; i < n; i++)
			cin >> s[i];

		sort(s,s+n);

		int sum = 0;
		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 p;
  int s[1000];
  int sum=0;
  while(1){
    cin>>p;
    if(p==0) break;
    for(int i=0;i<p;i++){
      cin>>s[i];
      sum+=s[i];
    }
    sort(s,s+p);
    for(int j=0;j<p;j++){
      /* cout<<s[j]<<endl;*/
    }
    cout<<sum-s[0]-s[p-1]<<endl;
  }
  return 0;
}

C++: #include<stdio.h>

void sort(int p[],int n);

void sort(int p[],int n)
{
    int i,j,temp;

    for (i = 0; i < n - 1; i++) {
        for (j = n - 1; j > i; j--) {
            if (p[j-1] > p[j]) {
                temp = p[j];
                p[j] = p[j-1];
                p[j-1] = temp;
            }
        }	
    }
}

int main(void)
{
	int i;
	int j;
	int k;
	int n;
	int d[20];
	int p[100];
	int sum;
	int ave;
	
	j=0;
	while(1){


		scanf("%d",&n);
		if(n==0) 
			break;
			
		for(i=0;i<n;i++){
		scanf("%d",&p[i]);
		}

		sort(p,n);	
	
		sum = 0;
		for(i=1;i<n-1;i++){
			sum += p[i];
		}
			
			d[j] = sum / (n-2);
			j++;

	}
	
	for(k=0;k<j;k++)
		printf("%d\n",d[k]);

	return 0;
}