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>
#include <vector>
#include <algorithm>

using namespace std;

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

C++: #include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>

using namespace std;
int main(){
	int n;
	while(1){
		cin >> n;
		if(n == 0) break;
		int s[n], i, sum = 0, ave = 0;
		for(i = 0;i < n;i++){
			cin >> s[i];
		}
		sort(s, s+n);
		s[0] = 0;
		s[n-1] = 0;

		for(i = 0;i < n;i++){
			sum += s[i];
		}
		ave = sum / (n-2);

		cout << ave << endl;
	}
	return 0;
}

C++: #include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int s[101];

int main(void) {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        int sum = 0;
        int ma = 0, mi = INF;
        for (int i = 0; i < n; i++) {
            cin >> s[i];
            ma = max(ma, s[i]);
            mi = min(mi, s[i]);
            sum += s[i];
        }
        sum -= (ma + mi);
        cout << sum / (n-2) << endl;
    }
    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    
    int minimum = 1e3, maximum = 0, sum = 0;
    for (int i = 0; i < n; i++) {
      int s;
      cin >> s;
      sum += s;
      minimum = min(minimum, s);
      maximum = max(maximum, s);
    }
    
    cout << (sum - minimum - maximum) / (n - 2) << '\n';
  }
}

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

using namespace std;

int main() {
    int n;
    while (true) {
        cin >> n;
        if (!n) { break; }

        vector<int> v(n);

        for (int i = 0; i < n; i++) { cin >> v[i]; }
        v.sort(v.begin(), v.end());

        int sum = 0;
        for (int i = 1; i < n-1; i++) {
            sum += v[i];
        }

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

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

C++: #include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  while(N != 0){
    vector<int> A(N);
    rep(i,N){
      cin >> A[i];
    }
    sort(A.begin(),A.end());
    int sum = 0;
    for(int i=1; i<N-1; i++){
      sum += A[i];
    }
    cout << sum/(N-2) << endl;
    cin >> N;
  }
  return 0;
}

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

using namespace std;

int main()
{
    for (;;) {
        int n, s[100];

        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));
    }

    return 0;
}

C++: int maximum = 0;
    for (int i=1; i<S; ++i)
        for (int j=i; j<S; ++j)
            if (tax(X,i)+tax(X,j) == S) // (*)
              maximum = max(maximum, tax(Y,i)+tax(Y,j));

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

int main(){
  int n,s;
  
  while(cin>>n && n!=0){
    int sum=0;
    int largest=0;
    int smallest=1000;
    
    for(int i=1;i<=n;i++){
      cin>>s;
      sum+=s;
      if(largest<s)  largest=s;
      if(smallest>s) smallest=s;
    }
    int result=sum-largest-smallest;

    cout<<(int)(result/(n-2))<<endl;
}

}

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

int main(){
    int n;

    while(cin>>n,n){
        vector<int> v(n);

        for(auto &t:v){
            cin>>t;
        }

        sort(v.begin(),v.end());
        cout << accumulate(v.begin()+1,v.end()-1,0) / (n-2) << endl;
    }
}

C++: #include<cstdio>
#include<cstdlib>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;

int main(){
  int n,min,max,result;
  int score[100];

  while(true){

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

    result = 0;
    min = 1000;
    max = 0;

    REP(i,n){
      int score;
      cin >> score;
      if(max < score) max = score;
      if(min > score) min = score;
      result += score;
    }
    cout << (result - max - min)/(n-2) << endl;
  }
  return 0;
}