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(){
	int n;
	int total;
	int ave;

	while(1){
		vector<int> v;
		cin>>n;
		if(n==0)break;

		for(int i=0;i<n;i++){
			cin>>tmp;
			v.push_back(tmp);
		}

		sort(v.begin(),v.end());

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

		total=total-(v[0]+v[n-1]);
		ave=total/(n-2);
		
		cout<<ave<<endl;
		
	}
}

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

int main()
{
    int x;
    while(1){
        cin >> x;
        if(x == 0) break;
        int max = -1, mini = 10000, sum = 0, score = 0, y = 0;
        for(int i = 0; i < x; i++){
           cin >> score;
          sum += score;
          if(score > max) max = score;
            if(score < mini) mini = score;
        }
        sum -= max + mini;
        y = sum / (n - 2);
        cout << y << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
  int n;
  int point[100], average;
  
  while(1){
    average = 0;
    cin >> n;
    if(n == 0) break;

    for(int i = 0 ; i < n ; i++){
      cin >> point[i];
    }
    sort(point, point + n);
    for(int i = 1 ; i < n - 1 ; i++){
      average += point[i];
    }
    average /= (n-2);
    cout << average << endl;
  }
  return 0;
}

C++: #include <stdio.h>
 
int main(){
    int n,s[1024]={0};
        int max,min,max1,min1;
        int sum,i;
 
scanf("%d\n",&n);
 
do {
        max=0;
        min=100000;
        sum=0;
        sum=0;
    max1=0;
    min1=0;
        for (i=0;i<n;i++){
                scanf("%d\n",&s[i]);
                if(s[i]>max){
            max=s[i];
                        max1=i;
                }
                if(s[i]<min){
                        min=s[i];
            min1=i;
                }
        }
        for(i=0;i<n;i++){
                if(i!=max1&&i!=min1){
                        sum+=s[i];
                }
        }
        printf("%d\n",sum/(n-2));
        scanf("%d\n",&n);
}while (n!=0);
return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  while (true) {
    int n; cin >> n;
    if (n == 0) break;
    V<> a(n); for (int i = 0; i < n; ++i) cin >> a[i];
    sort(begin(a), end(a));
    int res = accumulate(next(begin(a)), prev(end(a)), 0) / (n - 2);
    cout << res << '\n';
  }
}

C++: gag

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

int main() {
        int i, j;
        int n;
        while (cin >> n) {
                if (n == 0) break;
                int sum = 0;
                vector<int> a(n);
                for (i = 0; i < n; i ++) {
                        cin >> a[i];
                        sum += a[i];
                }
                sort(a.begin(), a.end());
                sum -= a.front();
                sum -= a.back();
                cout << sum / (n - 2) << endl;
        }
        return 0;
}

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

int main(){
    while(1){
        int N;
        cin >> N;
        if(N==0)
            break;
        int s[111];
        for (int i = 0; i < N; i++)
            cin >> s[i];
        int M=-1, m=1111, sum = 0; // M:最大値, m:最小値
        for (int i = 0; i < N;i++){
            M = max(M, s[i]);
            m = min(m, s[i]);
            sum += s[i];
        }
        int ans = (sum - M - m) / (N - 2);
        cout << ans << endl;
    }
}

C++: #include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    while(N){
        int sum = 0,a,maxi = 0,mini = INF;
        rep(i,0,N){
            cin >> a;
            sum += a;
            maxi = max(maxi, a);
            mini = min(mini, a);
        }
        sum -= (maxi + mini);
        cout << sum / N << endl;
        cin >> N;
    }
}

C++: #include<stdio.h>

int main(){

int n;
int P[102]={};
while(1){
scasnf("%d",&n);if(n==0)break;
for(int i=0;i<n;i++)
scanf("%d",&P[i]);

int s=0;
for(int i=0;i<n;i++)
for(int j=n-1;j>i;j--)
if(P[j]>P[j-1]){int t=P[j];P[j]=P[j-1];P[j-1]=t;}

for(int i=0;i<n;i++)
if(i!=0&&i!=n-1)s+=P[i];

s=s/n;
printf("%d\n",s);
}
return 0;
}

C++: #include<iostream>
#include<algorithm>
 
using namespace std;
 
int main(){
    while( true ){
        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);

        for(int i = 2;i < n-1;i++){
            a[1]+=a[i];
        }

        cout << a[1]/(n-2) << endl;
    }   
 
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#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[])
{
	

	while(1){
		int ans=0;
		int i=0;
		int temp=0;
		int a=0;
		int ninzu=0;
		vector <int>  s;

		cin >> ninzu;

		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 N, A[1024],Max,Min,Sum;

int main(){
 while(cin >> N && N>0){
  for (int i=0; i<N; ++i)
    cin >> A[i];
  for (int j=0; j<N; ++j){
    Max=A[0];
	if(A[j]>Max) Max=A[j];
    }
  for (int k=0; k<N; ++k){
    Min=A[0];
	if(A[k]<Min) Min=A[k];
	}
  for (int l=0; l<N; ++l){
    Sum += A[l];
	}
  cout<< (Sum-Max-Min)/(N-2) << endl;
  Sum=0;
  Max=0;
  Min=0;
 }
}