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

package main

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

// 標準入力を取得するScannerのインスタンスを作成
var sc = bufio.NewScanner(os.Stdin)

// 標準入力で各行を読み込み文字列として返す
func readLine() string {
	if sc.Scan() {
		return sc.Text()
	}
	return ""
}

func average() (avg int) {
	// 審判の人数を取得する
	n, _ := strconv.Atoi(readLine())

	// 得点
	score := make([]int, 0, n)

	// 得点を読み込む
	for n > 0 {
		line, _ := strconv.Atoi(readLine())
		score = append(score, line)
		n--
	}

	if len(score) == 0 {
		return 0
	}

	// ソート
	sort.Ints(score)
	// 先頭を削除
	score = append(score[:0], score[1:]...)
	// 末尾を削除
	score = score[:len(score)-1]

	// 合計
	for i := 0; i < len(score); i++ {
		avg += score[i]
	}

	// 平均
	avg = avg / len(score)
	return avg
}

func main() {
	// 改行区切りから単語(スペース)区切りで読み込むように変更する
	sc.Split(bufio.ScanWords)
	for {
		avg := average()
		if avg != 0 {
			fmt.Println(avg)
		} else {
			break
		}
	}
}

C++: 
#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[])
{
			int ninzu=0;
	while(cin >> ninzu){
		int ans=0;
		int i=0;
		int temp=0;
		int a=0;

		vector <int>  s;

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

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

		ans = ans / (i-1);

		cout << ans << endl;
		ans=0;
	}

    return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
	int n,s,inputNum,minNum,maxNum;
	
	while(cin>>n,n){
		minNum=(int)1e+8;
		s=maxNum=0;
		
		for(int i=0;i<n;i++){
			cin>>inputNum;
			s+=inputNum;
			if(inputNum<minNum){
				minNum=inputNum;
			}
			if(inputNum>maxNum){
				maxNum=inputNum;
			}
		}
		
		s=s-maxNum-minNum;
		s=s/(n-2);
		
		cout<<s<<endl;
	}
}

C++: #include<iostream>
using namespace std;
int main(){
int judge;
int maxscore =0;
int minscore =0;
cin >> judge;
if(judge != 0){
int score[judge];
	for(int i=0; i<judge; i++){
	cin >> score[i];
		if(score[i] > maxscore){
		maxscore = score[i];
		}
		if(score[i] < minscore){
		minscore = score[i];
		}
		if(i==0){
		minscore = score[0];
		}
	}
int lastscore = 0;
for(int j=0;j<judge;j++){
lastscore +=  score[j];
}
lastscore = (lastscore - maxscore - minscore)/(judge - 2);
cout << lastscore <<endl;
}
return 0;
}

C++: #include <iostream>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <bitset>
#include <tuple>

using namespace std;

int main(void)
{
  while (true) {

    int n;
    cin >> n;
    if (n == 0) break;
    int p[n];
    for (int i = 0; i < n; i++)
      cin >> p[i];
    int top,bottom,sum;
    top = -1;
    bottom = 1001;
    sum = 0;
    for (int i = 0; i < n; i++) {
      if (top < p[i])
	top = p[i];
      if (bottom > p[i])
	bottom = p[i];
    }
    //cout << top << "  " << bottom << endl;
    
    bool t, b;
    t = b = true;
    for (int i = 0; i < n; i++) {
      if (top == p[i] && t) {
	t = false;
      }
      else if (bottom == p[i] && b) {
	b = false;
      }
      else
	sum+=p[i];
    }
    cout << (int)(sum/(n-2)) << endl;
    
  }
  return 0;	
}

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

int main(){
  while (1){
    int n,p,sum=0;
    cin >> n;
    if (n==0) return 0;
    vector<int> points;
    for(int i=0;i<n;i++){
      cin >> p;
      points.push_back(p);
    }
    sort(points.begin(),points.end());
    points.erase(points.begin());
    points.pop_back();
    for (int i=0;i<points.size();i++){
      sum+=points[i];
    }
    cout << floor(sum/points.size()) << endl;
  }
}

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

int main(){
  int n;
  int maxs,mins,sum;
  while(cin>>n,n){
    sum=0;
    maxs=0;
    mins=2000;
    for(int i=0,tmp;i<n;i++){
      cin>>tmp;
      sum+=tmp;
      maxs=max(maxs,tmp);
      mins=min(mins,tmp);
    }
    sum-=mins;
    sum-=maxs;
    cout<<sum/(n-2)<<endl;
  }
}

C++: #include<iostream>
typedef long long ll;
using namespace std;
int main(){
  ll N;
  ll s[1100];
  ll sum=0;
  ll t=1;
  while(N){
  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;
  cin>>N;
}
}

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

int main(){
	int n, s, sum, max, min, i;
	while((cin >> n), n){
		sum = max = 0;
		min = 1000;
		for(i = 0; i < n; i++){
			cin >> s;
			sum += s;
			max = max(max, s);
			min = min(min, s);
		}
		cout << (int)(sum / n) << endl;
	}
}

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

int n, sum, l, s;

int main() {
  
  int a;
  while(cin>>n,n) {
    cin>>a;
    sum = a;
    l = a;
    s = a;
    for(int i=1;i<n;i++) {
      cin>>a;
      if(a>l)l=a;
      else if(a<s)s=a;
      sum+=a;
    }
    sum -= l+s;
    sum = sum/(n-2);
    cout<<sum<<endl;
  }
  
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
int n;
while(cin >> n, n){
vector<int> v(n);
for(int i = 0; i < n; i++){
cin >> v[i];
}
sort(v.begin(), v.end());
int sum = 0;
for(int i = 1; i < n-1; i++){
sum+=v[i];
}
cout << sum / (n-2) <<endl;
}


}

C++: #include <stdio.h>
 
int main() {
 
  int n,a[100] = {0};
  int i,j,k,l;
  int sum;
  int suma[30];
  j = 0;
  while(1) {
 int max = -1;
  int min = 10001;
   sum = 0;
 
  scanf("%d",&n);
  if(n == 0){
    break ;}
 
  for(i=0;i<n;i++) {
 
    scanf("%d",&a[i]);
    sum = sum + a[i];
    if(min > a[i] ) {
      min = a[i];
    } if( max < a[i]) {
      max  = a[i];
    }
  } 
 sum = (sum-max-min) / (n-2);
 suma[j] = sum;
 j++;
 
  }
 
  //  printf("sum = %d\n",sum);
  // printf("max = %d min = %d",max,min);
 
  for(i = 0; i < j; i++) {
 
  printf("%d\n",suma[i]);
   
  }
 
  return 0;
 
}

C++: #include<iostream>
using namespace std;
int main(){
    int n,i;
    while(cin >> n,n){
		int p;
        int min = 1000;
        int max = 0;
		int total = 0;
		for(int i=0;i<n;i++){
			cin >> p;
			if(p > max) max = p;
			if(p < min) min = p;
			total += p;
        }
        cout << (total-max-min)/(n-2) << "\n";
    }
}

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

int a[10];
int n;
int s[100];
int s_max, s_min;
int sum = 0;
int ave = 0;

int main() {
  while(cin >> n, n)
  {
  for(int i =0; i < n; i++){
    cin >> s[i];
  }
  
  s_max = *max_element(s, s + n);
  s_min = *min_element(s, s + n);

  sum = accumulate(s, s + n, 0);

  sum = sum - s_max - s_min;

  ave = sum/(n-2);
  cout << ave << endl;
  }
  return 0;
}

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

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

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

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

int n,s;

int main(){
    while(cin>>n&&n){
	int sum=0,M=0,m=1000;
	rep(i,n){cin>>s;sum+=s;if(s>M)M=s;if(s<m)m=s;}
	cout<<(sum-M-m)/(n-2)<<endl;
    }
}