Go: // ICPC 得点集計ソフトウェア
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp
package main

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

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

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

		score_list := []int{}
		for i := 0; i < n; 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))
	}
}

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

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
using namespace std;
int main() {
	while (true) {
		int n = 0;
		scanf("%d", &n);
		if (n == 0) break;
		vector<int> a;
		for (int i = 0;i < n;++i) {
			int b = 0;scanf("%d",&b );
			a.push_back(b);
		}
		sort(a.begin(), a.end());
		int num = 0;
		for (int i = 0;i < n;++i) {
			num += a[i];
		}
		num -= (a[0] + a[n - 1]);
		printf("%d\n", num/(n-2));
	}
}

C++: #include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	int n, max, min, s, t;
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		min = 1001;
		max = s = 0;
		for(int i = 0; i < n; i++){
			cin >> t;
			if(t < min){
				min = t;
			}
			if(max < t){
				max = t;
			}
			s += t;
		}
		
		cout << (s-min-max)/(n-2) << endl;
	}
	
	return 0;
}

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

using namespace std;

int main(){
	vector<int> array;
	int i,x,max,min,sum;
	max = 0;
	min = 1000;

	while(cin>>n){
	clear(array);
	sum=0;

	for(i=0;i<sizeof(array);i++){
		cin >> x;
		array.push_back(x);
	}
	for(i=0;i<n;i++){
		if(max<array[i]){
			max= array[i];
		}
	}
	for(i=0;i<n;i++){
		if(min>array[i]){
			min= array[i];
		}
	}
	for(i=0;i<sizeof(array);i++){
		sum += array[i];
	}
	sum = sum-max-min;
	cout << sum/sizeof(array) << endl; 
	}

}

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

using namespace std;

int main(){
  int i, n, s, sum, avg;
  vector<int> data;

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

    for(i=0; i<n; ++i){
      cin >> s;
      data.push_back(s);
    }

    sort(data.begin(), data.end());

    for(i=1, sum=0; i<n-1; ++i)
      sum += data[i];

    avg = sum / (data.size()-2);

    cout << avg << endl;
    data.clear();
  }

  return 0;
}

C++: #pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
    int n;
  while(1){
   cin>>n;
   if(n==0)return 0;
   V<ll> a(n);
   ll sum=0;
   for(int i=0;i<n;i++){cin>>a[i];sum+=a[i];}
   sort(all(a));
   sum-=(a[0]+a[n-1]);
   cout<<sum/(n-2)<<endl;

  }
 
}

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

using namespace std;

int main(){
	
	int n;
	
	while(1){
		cin >> n;
		if(n==0) break;
		int s[n];
		
		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<iostream>
 
using namespace std;
 
int main(){
    while( true ){
        int n;
        int ma = 0;
        int mi = 1000;
        int s = 0;
        cin >> n;

        if (n == 0){
            break;
        }

        int a[n];

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

            if (a[i] < mi){
                mi = a[i]
            }
            
            if (a[i] > ma){
                ma = a[i]
            }
        }

        for(int i = 0; i < n; i++){
            s += a[i];
        }

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

    }   
    return 0; 
}

C++: #include<algorithm>
#include<iostream>
#define rep(i,a) for(int i=0;i<(a);++i)

int n;

int main()
{
	while( std::cin >> n )
	{
		int ma = 0, mi = 1001, S = 0;
	
		rep( i, n )
		{
			int a;
			std::cin >> a;
			ma = std::max( ma, a );
			mi = std::min( mi, a );
			S += a;		
		}
		
		std::cout << S-ma-mi << std::endl;
	}

	return 0;
}

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

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

using namespace std;
int main(){
	int n, max;
	int *score;

	while(1){
		cin >> n;
		if(n==0){
			break;
		}else{
			max = 0;
			score = new int[n];
			for(int i=0; i<n; i++){
				cin >> score[i];
			}
			sort(score, score+n);
			for(int i=1; i<n-1; i++){
				max += score[i];
			}
			cout << max/(n-2) << endl;

			delete [] score;
		}
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
        int n, s ;
	while (cin >> n && n > 0){
		int large = 0;
		int small = 1000;
		int sum = 0;
  		for (int i=0; i>n; ++i){
			cin >> s;
			sum = sum + s;
			if (large < s) {large = s;}
			if (small > s) {small = s;}
		}
		int ans = 0;
		ans = (sum - large - small) / (n - 2);
		cout << ans << endl ;
	}
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    while(1){
        vector<int> point;
        int n,x;
        long long sum=0;
        cin >> n;
        if(n==0)    break;
        while(n--){
            cin >> x;
            point.push_back(x);
        }
        sort(point.begin(),point.end());
        for(int i=1;i<point.size()-1;i++){
            sum+=point[i];
        }
        cout << sum/(point.size()-2) << "\n";
        point.clear();
    }
}

C++: #include <stdio.h>
#include <float.h> 
int main(void){	
  int n[10];	
  int a[1000];	
  int i,j,max[10],min[10],suma[10],sumb[10],ave[10]; 
  for(i = 0;;i++){  
    scanf("%d",&n[i]);
    if(n[i]==0)break;  
    for(j=0 ; j<n[i] ;j++){ 
      scanf("%d",&a[j]);
    } 
    max[i] = a[0];
    min[i] = a[0];
    suma[i] = 0; 
    for(j=0 ; j<n[i] ; j++){
      if(a[j] >= max[i]){
	max[i] = a[j];
      }
      if(a[j] <= min[i]){
	min[i] = a[j];
      }
      suma[i] += a[j];
    }
  } 

  for(j = 0;j < i;j++){
    sumb[j] = suma[j]-max[j]-min[j]; 
    n[j] -= 2;
    ave[j] = sumb[j] / n[j] ;
    printf("%d\n",ave[j]);    
  }
  return 0;
  
}