Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	for sc.Scan() {
		n, _ := strconv.Atoi(sc.Text())
		scores := make([]int, n, n)
		for i := 0; i < n; i++ {
			sc.Scan()
			scores[i], _ = strconv.Atoi(sc.Text())
		}
		sort.IntSlice(scores).Sort()
		var sum = 0
		for i := 1; i < n-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

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

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

C++: #include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <numeric>
using namespace std;

int main() {
    int i, j=0, n, p[200][200];
    while(cin >> n && n){
        for(i=0; i<n; i++) cin >> p[j][i];
        sort(p[j], p[j]+n);
        cout << accumulate(p[j]+1, p[j]+n-1, 0) / (n-2) << endl;
        j++;
    }
}

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

using namespace std;

#define ll long long

ll MIN(ll num1,ll num2){
    return num1<num2?num1:num2;
}

int main(){

    while(1){
        int N;
        vector<int> V;
        cin>>N;
        if(N==0)break;
        for(int i=0;i<N;i++){
            int v;
            cin>>v;
            V.push_back(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 <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

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

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

        vector<int> vec(n);
        rep(i, n) cin >> vec[i];

        int ans = accumulate(all(vec), 0);
        sort(all(vec));
        ans -= vec.front();
        ans -= vec.back();

        ans /= n-2;
        cout << ans << endl;
    }
}

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

int N, S;

int main(){
   while ( cin >> N && N>0){
      int M, m, addup;
      M = -1;
      m = 1001;
      addup = 0;
      for ( i = 0; i<N; i++){
         cin >> S;
         addup += S;
         if ( S > M) M = S;
         if ( S < m) m = S;
      }
   cout << (addup - M - m)/(n-2)  << endl;
   }
}

C++: #include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int n;
int x;
int main()
{
  while(cin>>n,n){
    int ans;
    double sum = 0;
    vector<int> V;
    for(int i = 0; i< n;i++){
      cin>>x;
      V.push_back(x);
    }
    sort(V.begin(),V.end());
    
    for(int i = 1;i <V.size()-1;i++){
      sum+=V[i];
    }
    ans =sum/(V.size()-2);
    cout <<ans<<endl;
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int N, S;

int main(){
  while( cin >> N && N > 0){ //N??????????????????????????????????????§while????????????
    int sum = 0; 
    int min = 0;
    int max = 0;
    int average = 0;

    for (int i = 0; i < N; cin >> S){
      sum += S;
      if( S > max ) max = S;
      else if(S < min) min = S; 
    }

    sum -= min + max;
    sum /= N - 2;

    //average = sum - min - max / N - 2; //???N-2?????§???????????¨?????¨??????

    cout << average << endl;
  }

  return 0;
}

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

int main() {
  while(1) {
    int n;
    std::cin >> n;
    if(n == 0)
      break;
    std::vector<int> v(n);
    for(int i = 0; i < n; i++) {
      std::cin >> v[i];
    }
    std::sort(v.begin(), v.end());
    int s = 0;
    for(int i = 1; i < n - 1; i++) {
      s += v[i];
    }
    std::cout << (s / (n - 2)) << "\n";
  }
  return 0;
}

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

typedef long long LL;
#define rep(i ,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define all(v) (v).begin(),(v).end()

typedef vector<int> vi;


int main(){
	int n;
	while (cin >> n){
		if (n == 0) break;
		vi score;
		int s;
		rep(i, n){
			cin >> s;
			score.push_back(s);
		}
		sort(all(score));
		int ans = 0;
		for (int i = 1; i < n - 1; i++){
			ans += score[i];
		}
		cout << ans / (n - 2) << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,s[100],ans=0,tmp;
  while(1){
    ans=0;
    cin>>n;
    if(n==0) break;
    for(int i=0;i<n;i++){
      cin>>s[i];
    }
    for(int i=0;i<n;i++){
      for(int j=n-1;i<j;j--){
	if(s[j]>s[j-1]){
	  tmp=s[j-1];
	  s[j-1]=s[j];
	  s[j]=tmp;
	}
      }
    }
    for(int i=1;i<n-1;i++){
      ans+=s[i];
    }
    ans/=(n-2);
    cout<<ans<<endl;
  }
return 0;
}

C++: #include<stdio.h>

void QSort(int x[ ], int left, int right);
void Swap(int x[ ], int i, int j);

void QSort(int x[ ], int left, int right)
{
    int i, j;
    int pivot;

    i = left;                   
    j = right;                  

    pivot = x[(left + right) / 2];
    while (1) {                   

        while (x[i] < pivot)      
            i++;                  

        while (pivot < x[j])      
            j--;                  
        if (i >= j)               
            break;                

        Swap(x, i, j);            
        i++;                      
        j--;
    }

    if (left < i - 1)              
        QSort(x, left, i - 1);     
    if (j + 1 <  right)            
				QSort(x, j + 1, right);    
		}

void Swap(int x[ ], int i, int j)
{
    int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}

int main(void)
{
	int i;
	int j;
	int k;
	int n;
	int d[20];
	int p[100];
	int sum;
	int ave;
	
	while(1){

		scanf("%d",&n);
		if(n==0) 
			break;
		
		j=0;
		for(i=0;i<n;i++){
		scanf("%d",&p[i]);
		}

		QSort(p,0,n-1);	
	
		sum = 0;
		for(i=1;i<n-1;i++)
			sum += p[i];
	
			d[j] = sum / (n-2);
			j++;
	}
	
	for(k=0;k<j;k++){
		printf("%d",d[k]);
	}
	
	return 0;