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 <bits/stdc++.h>

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    while(true){
        int N; cin >> N;
        int sum = 0;
        if(N == 0) break;
        vector<int> A(N);
        rep(i, N){
            cin >> A[i];
            sum += A[i];
        }
        sort(A.begin(), A.end());
        cout << (sum - A[0] - A[A.size()-1]) / (A.size()-2) << endl;
    }
    return 0;
}

C++: while true do

    max = -1
    min = 1001

    sum = 0

    n = gets.to_i


    n.times do
        v = gets.to_i
        min = v if v < min
        max = v if v > max
        sum += v
    end
    sum -= (min + max)
    p sum / (n-2)
end

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

C++: #include <bits/stdc++.h>
using namespace std;
int n;
int s[100];

int main() {
    while(true) {
        scanf("%d", &n);
        if (n == 0) break;
        for (int i=0; i<n; i++) scanf("%d", &s[i]);
        sort(s, s+n);
        int sum = 0;
        for (int i=1; i<n-1; i++) sum += s[i];
        printf("%d\n", sum / (n - 2));
    }
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <tuple>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    int sum=0,M=0,m=0;
    REP(i,n){
      int tmp;
      cin >> tmp;
      sum+=tmp;
      if(M<tmp) M=tmp;
      if(m>tmp) m=tmp;
    }
    cout << (sum-M-m)/(n-2) << endl;
  }
}

C++: #include<iostream>
#include<algorithm>
int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int n;
	int avg=0;
	int s[100];
	while (true){
		std::cin >> n;
		if (n == 0) break;
		int q = n - 2;
		for (int i = 0; i < n; i++){
			std::cin >> s[i];
		}
		std::sort(s, s + n);
		for (int i = 1; i <= n-2; i++){
			avg += s[i];
			s[i-1] = 0;
			s[i] = 0;
		}
		std::cout << avg /q << "\n";
		int avg = 0;
		
	}
}

C++: #include <iostream>

#include <algorithm>
#include <numeric>

#include <vector>
#include <queue>
#include <stack>
#include <map>

#define FOR(i,b,e) for(int i=b;i<e;i++)
#define REP(i,n) FOR(i,0,n)

using namespace std;

typedef pair<int, int> P;

const int MAX_N = 100;
int n;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  while (true) {
    vector<int> scores;

    cin >> n; 
    if (n == 0) break;

    REP(i,n) {
      int s;
      cin >> s;
      scores.push_back(s);
    }

    sort(scores.begin(), scores.end());
    int sum = accumulate(scores.begin() + 1, scores.end() - 1, 0);

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

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

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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	int n;
	while(cin >> n, n){
		vector<int> v(n);
		int ma = -1, mi = inf;
		bool a = true, b = true;
		for(int i=0; i < n; i++){
			cin >> v[i];
			if(ma < v[i]) ma = v[i];
			if(v[i] < mi) mi = v[i];
		}
		int sum = 0;
		rep(i, v.size()){
			if(ma == v[i] && a){a = false; continue;}
			if(mi == v[i] && b){b = false; continue;}

			sum += v[i];
		}
		cout << sum/(v.size()-2) << endl;
	}
}

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a,n;
    for(;;){
        vector<int> num;
        cin>>n;
        if(n==0) break;
        for(int i = 0; i < n; i++){
            cin>>a;
            num.push_back(a);
        }
        sort(num.begin(), num.end());
        num.erase(num.begin());
         num.pop_back();
        int sum=0;
        for(int x : num){
            sum+=x;
        }
        sum/=num.size();
        cout<<sum<<endl;
    }
    return 0;
}

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

int main()
{
	while (true)
	{
		int n;
		scanf("%d", &n);
		if (!n) break;
		
		std::vector<int> points(n);
		for (auto& e: points) scanf("%d", &e);
		std::sort(points.begin(), points.end());
		int sum{};
		for (int i{1}; i < n - 1; i++)
			sum += points[i];
		printf("%d\n", sum / (n - 2));
	}

	return 0;
}

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

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

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

int main(){
  int n, s, sum, max, min;
  while(1){
    cin >> n;
    if(n == 0) break;
    sum = 0;
    cin >> s;
    sum += s;
    max = s;
    cin >> s;
    sum += s;
    if(max < s){
      max = s;
    }else{
      min = s;
    }
    for(int i = 2; i < n; i++){
      cin >> s;
      sum += s;
      if(max < s){
	max = s;
      }else if(min > s){
	min = s;
      }
    }
    sum -= max;
    sum -= min;
    int ave = sum / (n-2);

    cout << ave << endl;
  }

  return 0;
}