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>
using namespace std;

int main() {
	int n, i, p[100], t;
	int max, min, maxi, mini;
	cin >> n;
	
	while (n != 0){
		max = 0; min = 1000; t = 0;

		for (i = 0; i < n; i++) {
			cin >> p[i];
		}

		for (i = 0; i < n; i++) {
			t += p[i];

			if (p[i] > max) {
				maxi = i;
				max = p[i];
			}

			if (p[i] < min) {
				mini = i;
				min = p[i];
			}
		}

		cout << (t - p[maxi] - p[mini]) / (n - 2) << endl;

		cin >> n;
	}
}

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

int main(){
  int n;
  vector<int> v;
  while(cin>>n,n){
    v.clear();
    int tmp;
    for(int i=0;i<n;i++){
      cin>>tmp;
      v.push_back(tmp);
    }
    sort(v.begin(),v.end());
    int sum=0;
    for(int a:v){
      sum+=a;
    }
    sum-=v[0];
    sum-=v[v.size()-1];
    cout << sum / (v.size()-2)<< endl;
  }
  return 0;
}

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

int main(){

  int n, s,  min, max;
  int total;
  while(cin >> n){
    total = 0;

   if(n == 0) break;

    for(int i=0; i<n; i++){
      cin >> s;
      if(i == 0){
	min = s;
	max = s;
      }
      if(s < min) min = s;
      if(s > max) max = s;
      total += s;
    }
    cout << (total-min-max)/(n-2) << endl; 
  }
  return 0;
}

C++: #include <stdio.h>
int main(){
	int n,s,sum,i,max,min,ave;
	
	while(1){
		sum=0;
		max=0;
		min=1000;
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%d",&s);
			sum+=s;
			if(s>max)max=s;
			if(s<min)min=s;
		}
		ave=(sum-(max+min))/(n-2);
		printf("%d\n",ave);
	}
	return 0;
}

C++: #include<stdio.h>
#include<math.h>

int main(void){
	
	int n,i,flag;
	int max,min;
	int readed,ans;
	double avg;
	
	while(1){
		
		flag = 0;
		
		scanf(" %d",&n);
		
		if(n==0){
			break;
		}
		
		for(i = 0;i < n;i++){
			
			scanf(" %d",&readed);
			
			if(flag == 0){
				max = readed;
				min = readed;
				flag = 1;
			}
			
			if(max < readed){
				max = readed;
			}
			
			if(min > readed){
				min = readed;
			}
			
			avg += readed;
		}
		
		avg -= max + min;
		
		avg /= n - 2;
		
		ans = (int)floor(avg);
		
		printf("%d\n",ans);
		
	}
	
	return(0);
	
}

C++: #include <iostream>

using namespace std;

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

C++: #include <iostream>

int main()
{
    int n, s = 0;
    std::cin >> n;

    int max, min, sum = 0;
    std::cin >> s;
    max = s;
    min = s;
    sum += s;

    for (int i = 0; i < n - 1; i++) {
        std::cin >> s;
        if (s > max)
            max = s;
        if (s < min)
            min = s;
        sum += s;
    }
    std::cout << (sum - max - min) / (n - 2) << '\n';

    return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
  while (true) {
    int n;
    cin >> n;
    if (n == 0)
      break;

    int score[100];
    for (int i = 0; i < n; i++)
      cin >> score[i];

    sort(score + 0, score + n);
    int sum = accumulate(score + 1, score + n - 1, 0);

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

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


main(){
	int i,n,sum,mmin,mmax,t;
	while(cin>>n,n){
		sum=0;mmin=1000;mmax=0;
		for(i=0;i<n;i++){
			cin >> t;
			sum+=t;
			mmin = min(mmin,t);
			mmax = max(mmax,t);
		}
		cout << (sum-mmin-mmax)/(n-2) << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
	int a[20];
	int b,sum=0,point;
	while(1){
		cin >> b;
		if(b==0) break;
		for(int i=0;i<b;i++){
			cin >> a[i];
			
		}
		sort(a,a+b);
		for(int j=1;j<b-1;j++){
			sum+=a[j];
		}
		point=sum/(b-2);
		cout << point << endl;
		sum=0;
		
	}
	return 0;
}

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

int main(){
	int n;
	while(scanf("%d",&n),n){
		vector < int > vi;
		for(int i = 0; i < n; i++){
			int tmp;
			scanf("%d",&tmp);
			vi.push_back(tmp);
		}
		sort(vi.begin(),vi.end());
		double ave = 0.0;
		for(int i = 1; i < n-1 ;i++){
			ave += vi[i];
		}
		printf("%.0lf\n",ave/(n-2));
	}
	return 0;
}

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


int main(){
  while(true){
    int n;
    cin>>n;
    if(n==0){
      break;
    }
    int avn=n-2,s[n],total=0;
    for(int k=0;k<n;k++){
      cin>>s[k];
      total=total+s[k];
    }
    int max=0,min=1000;
    for(int i=0;i<n;i++){
      if(s[i]>max){
	max=s[i];
      }
      if(s[i]<min){
	min=s[i];
      }
    }
    total=total-max-min;
    total=total/avn;
    cout<<total<<endl;
  }

  return 0;
}

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

using namespace std;
int main(){
    int n=1;
    while (true){
        cin >> n;
        if(n==0) break;
        vector<int> a(n);
        for (int i = 0 ;i<n;i++){
            cin >> a[i];
         }
        sort(a.begin(),a.end());
        int sum=0;
        for (int i=0;i<n-1;i++){
            sum+=a[i];
        }
        cout << (float) sum /(float) (n-2)<<endl;
    }
}

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

int n,s[100];
int temp,ave,sum;

void sort(void){
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      if(s[i]>s[j]){
	temp=s[i];
	s[i]=s[j];
	s[j]=temp;
      }
    }
  }
}

int main(){
  while(cin >> n,n){
    for(int i=0;i<n;i++)
      cin >> s[i];  
    
    sort();
    
    sum=0;

    for(int i=0;i<n-2;i++)
      sum+=s[i+1];

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

C++: #include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e18;
const int inf=2e9;
const ll MOD=1000000007;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};

int main(){
    while(true){
        int N;cin>>N;
        if(N==0)break;
        int info[N];
        rep(i,N)cin>>info[i];
        sort(info,info+N);
        int sum=0;
        rep(i,N-2)sum+=info[i+1];
        int ans=sum/(N-2);
        cout<<ans<<endl;
    }
    return 0;
}