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++: #include <iostream>
using namespace std;

int N, S;

int main()
{
   while ( cin >> N && N>0)
   {
      int M, m, addup, i;
      M = -1;
      m = 1001;
      addup = 0;
      for ( i = 0; i<N; i++)
      {
         cin >> S;
         addup += S;
         if ( S > M) M = S;
         if ( S < m) m = S;
      }
   cout << (addup - M - m)/(N-2)  << endl;
   }
}

C++: #include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  while(1){
    int n;
    cin>>n;
    if(n==0) break;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    int sum=0;
    for(int i=1;i<n-1;i++){
      sum+=a[i];
    }
    cout<<sum/(n-2)<<endl;
  }
  return 0;
}

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

using namespace std;

int main(){
  int n;
  while(cin>>n){
    if(n==0)break;
    vector<int> score(n);
    for(int i=0;i<n;i++)cin>>score[i];

    vector<int>::iterator minIt = min_element(score.begin(),score.end());
    int minIndex = distance(score.begin(),minIt);
    score.erase(score.begin()+minIndex-1);

    vector<int>::iterator maxIt = max_element(score.begin(),score.end());
    int maxIndex = distance(score.begin(),maxIt);
    score.erase(score.begin()+maxIndex-1);

    int sum = accumulate(score.begin(),score.end(),0);
    cout << sum/score.size() << endl;
  }
  return 0;
}

C++: #include<stdio.h>
#include<math.h>
#define MAX 1000

int main(void){
	
	int i,n,max,min,sum,a[100],t;
	
	while(t != 1){

scanf("%d",&n);

if(n != 0){
	for(i = 0 ; i < n ; i++){
		a[i] = 0;
	}
	sum = 0;
	for(i = 0 ; i < n ; i++){
	scanf("%d",&a[i]);
	sum = sum + a[i];
	}
	max = a[0];
	for(i = 0 ; i < n ; i++){
		if(max < a[i]){
			max = a[i];
		}
	}
	
	min = a[0];
	for(i = 0 ; i < n ; i++){
		if(min > a[i]){
		min = a[i];
		}
	}
	
	sum = sum - max - min;
	
	n = n - 2;
	printf("%d\n",sum/n);
	
}

if(n == 0){
t = 1;
}

}

return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
	int n;
	int sum, max, min;
	
	while( 1 ){
		sum = 0; max = 0; min = 1000;
		cin >> n;
		vector<int> score(n);
		if( n == 0 ) break;
		for( int i = 0; i < n; i++ ){
			cin >> score[i];
			sum += score[i];
			if( max < score[i] ) max = score[i];
			if( min > score[i] ) min = score[i];
		}
		sum -= max + min;
		cout << sum/(n-2) << endl;
		score.clear();
	}
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = 3.141592653589793;
int n;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (cin >> n,n) {
        int  s[105]={};
        rep(i,n) cin >> s[i];
        sort(s,s+n);
        int ans=0;
        rep2(i,1,n-1) ans+=s[i];
        cout << ans /(n-2) << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

void print_vec(vector<int> vec)
{
  cout << "[";
  for (int i = 0; i < vec.size(); i++)
  {
    cout << vec.at(i);
    if (i < vec.size() - 1)
    {
      cout << ", ";
    }
  }
  cout << "]...size: " << vec.size() << endl;
}

int main()
{
  vector<int> vec;

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

    int least = 1001;
    int most = 0;
    int sum = 0;

    rep(i, n)
    {
      int x;
      cin >> x;
      least = min(least, x);
      most = max(most, x);
      sum += x;
    }

    int ave = (sum - least - most) / (n - 2);
    vec.push_back(ave);
  }

  for (auto &&i : vec)
  {
    printf("%d\n", i);
  }
}

C++: #include<iostream>
using namespace std;
 
int main(){
    int n,i;

    while(1){
        int point[100]={0,};
        int min = 1000;
        int max = 0;
		long total = 0;
        cin >> n;
        if(!n) break;
        for(i=0;i<n;i++){
            cin >> point[i];
            if(point[i] > max) max = point[i];
            if(point[i] < min) min = point[i];
			total += point[i];
        }
        cout << (total-max-min)/(n-2) << "\n";
    }

}

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

int main() {
  int n;
  while (cin >> n && n) {
    int s[110];
    for (auto i=0; i<n; i++) {
      cin >> s[i];
    }
    int max = 0;
    int min = 1010;
    int sum = 0;
    for (auto i=0; i<n; i++) {
      sum += s[i];
      if (max < s[i]) max = s[i];
      if (min > s[i]) min = s[i];
    }
    cout << (sum - max - min)/(n-2) << endl;
  }
}

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define INF 1e09

using namespace std;

int main(){
  int n;
  int total, maxim, minim;
  int tmp;
  while(cin >> n){
    total = 0; maxim = -INF; minim = INF;
    REP(i, n) { cin >> tmp; total += tmp; maxim = max(maxim, tmp); minim = min(minim, tmp); }
    total -= (maxim + minim);
    cout << total / (n - 2) << endl;
  }
  return 0;
}

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

//vector??????????§£???
int main(){
	while (1){
		int n;
		cin >> n;
		//???????????¶
		if (n == 0) break;
		//??\???
		vector<int> num;
		for (int i = 0; i < n; i++){
			int tmp;
			cin >> tmp;
			num.push_back(tmp);
		}
		//????¨????????°????????????§???????¨????
		int max = -1;
		int min = 99999;
		int sum = 0;
		for (int i = 0; i < num.size(); i++){
			if (num[i] >= max) max = num[i];
			if (num[i] <= min) min = num[i];
			sum += num[i];
		}
		//??????????¨????
		int avg = floor((sum - max - min) / (n - 2));
		cout << avg << endl;
	}
	return 0;
}