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 <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

int main() {
  int n, tmp;
  while (cin >> n, n) {
    vector<int> score;
    for (int i = 0; i < n; i++) {
      cin >> tmp;
      score.pb(tmp);
    }
    sort(score.begin(), score.end());
    int sum = 0;
    for (int i = 1; i < n-1; i++) {
      sum += score[i];
    }
    cout << sum/(n-2) << el;
  }
}

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

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

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

int main(){
  int n;
  int sum,maxv,minv,tmp;

  while(cin >> n){
    if(n==0)break;
    
    cin >> sum;
    maxv = minv = sum;
    for(int i=0;i<n-1;i++){
      cin >> tmp;
      sum += tmp;
      if(maxv < tmp)maxv = tmp;
      if(minv > tmp)minv = tmp;
    }

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

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

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

using namespace std;

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

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

int main(void){
	int judg;
	
	while(1){
		cin >> judg;
		if(judg==0)break;

		//点数入力
		int *score = new int[judg];
		for(int i=0; i<judg; i++)
			cin >> score[i];
		
		//最高点最低点求める
		int max=0,min=0;
		for(int i=0; i<judg; i++){
			if( score[max]<score[i] ) max=i;
			if( score[min]>score[i] ) min=i;
		}
		
		//平均点求める
		int avg=0;
		for(int i=0; i<judg; i++){
			if(i!=max&&i!=min)
				avg+=score[i];
		}
		avg = avg/(judg-2);

		cout << avg << endl;
	}
}

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

using namespace std;

int main()
{
  int n, a[101], t;

  while(cin>>n && n){
    for(int i = 0; i < n; i++){
      cin >> a[i];
    }
    sort(a, a+n);
    t = 0;
    for(int i = 1; i < n-1; i++){
      t += a[i];
    }

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

  return 0;
}

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

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

C++: #include <iostream>

int main() {
	while (true) {
		int referee;
		std::cin >> referee;
		if (referee == 0) {
			break;
		}

		int max, min;
		std::cin >> max >> min;
		if (max < min) {
			std::swap(min, max);
		}
		int total = 0;
		for (int i = 2; i < referee; ++i) {
			int score;
			bool updated;
			std::cin >> score;
			if (max < score) {
				total += max;
				max = score;
				updated = true;
			}
			if (min > score) {
				total += min;
				min = score;
				updated = true;
			}
			if (!updated) {
				total += score;
			}
		}
		std::cout << (total / (referee - 2)) << std::endl;
	}
}

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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {
	while (1) {
		int n;
		int s[101];
		int mini = INF;
		int maxi = -1;
		int total = 0;

		cin >> n;
		if (n == 0) {
			break;
		}
		FOR(i, 1, n) {
			cin >> s[i];
			if (maxi < s[i]) {
				maxi = s[i];
			}
			else if (mini > s[i]) {
				mini = s[i];
			}
			total += s[i];
		}
		cout << (total-maxi-mini) / (n - 2) << endl;
	}


}

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

int main(void){
	int n,m,max,min,answer;
	while(1){
		cin >> n;
		max = 0;
		min = INT_MAX;
		answer = 0;
		if (!n) break;
		for (int i=0;i< n;i++){
			cin >> m;
			if (m > max) max = m;
			else if (m < min) min = m;
			answer += m;

		}
		cout << answer-max-min << endl;

	}

	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
bool test = true;
int num;
while(test)
{
int ans = 0;
cin >> num;
if(num != 0)
{
int a[num];
for(int i = 0;i<num;i++)
{
 cin >> a[i];
}
sort(a, a + num);
for(int i=1; i<num-1;i++)
{
ans += a[i];
}
cout << ans << endl;
}
else
{
return 0;
}
}
}

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

using namespace std;

void find_max(int data[], int N){
  int flag = -1;
  int max = 0;
  for (int i=0; i<N; ++i){
    if (max < data[i]){
      max = data[i];
      flag = i;
    }
  }
  data[flag] = 0;
}

void find_min(int data[], int N){
  int flag = -1;
  int min = 1000000;
  for (int i=0; i<N; ++i){
    if (min > data[i]){
      min = data[i];
      flag = i;
    }
  }
  data[flag] = 0;
}

int main(void){
  int n;
  while (cin >> n){
    if (n == 0){
      return -1;
    }
    
    int data[20];
    
    for (int i=0; i<n; ++i){
      cin >> data[i];
    }
    find_min(data, n);
    find_max(data, n);
    int sum = 0;
    for (int i=0; i<n; ++i){
      sum += data[i];
    }
    int total = floor((double)sum/(n-2));
    cout << total << endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int judge;
int maxscore =0;
int minscore =0;
int totalscore = 0;
cin >> judge;
if(judge != 0){
	int score;	
	for(int i=0; i<judge; i++){
	cin >> score;
		if(score > maxscore){
		maxscore = score;
		}
		if(score < minscore){
		minscore = score;
		}
		if(i==0){
		minscore = score;
		}
	totalscore += score;
	}

int lastscore = (totalscore - maxscore - minscore)/(judge - 2);
cout << lastscore <<endl;
}
return 0;
}

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

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