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())
		if n == 0 {
			break
		}
		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 < len(scores)-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

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


int main(void){
  while(1){
    int n;
    std::vector<signed int> s;
    std::vector<signed int>::iterator it;

    std::cin >> n;
    if(n == 0) return 0;
    for(int i=0; i < n; i++){
      int inputting;
      std::cin >> inputting;
      s.push_back(inputting);
    }


    int max = -1, min = INT_MAX;
    std::vector<signed int>::iterator maxind;
    std::vector<signed int>::iterator minind;
    for(it = s.begin(); it != s.end(); ++it){
      if(*it > max){
        max = *it;
        maxind = it;
      }
    }
    s.erase(maxind);

    for(it = s.begin(); it != s.end(); ++it){
      if(*it < min){
        min = *it;
        minind = it;
      }
    }
    s.erase(minind);

    int sum = 0, avr;
    for(it = s.begin(); it != s.end(); it++){
      sum += *it;
    }
    std::cout << sum / s.size() << std::endl;
  }
}

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

int main(){
    int n;

    while(true){
        vector<int> point;
        int data;
        int ave=0;

        cin>>n;
        if(n==0){
            break;
        }
        for(int i=0; i<n; i++){
            cin>>data;
            point.push_back(data);
        }
        sort(point.begin(), point.end());
        for(int i=1; i<point.size()-1; i++){
            ave+=point[i];
        }
        cout<<ave/(point.size()-2)<<endl;
    }

    return 0;
}

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

typedef long long ll;

vector<int> score;

int main()
{
    int n;
    while(cin >> n && n) {
        score.resize(n);
        for(int i = 0; i < n; i++) 
            cin >> score[i];

        sort(score.begin(), score.end());
        int sum = 0;
        for(int i = 1; i < n - 1; i++) 
            sum += score[i];
             
        cout << sum / (n - 2) << endl;
           
    }
}

C++: #include <iostream>

int main()
{
    int n, s = 0;
    while (std::cin >> n && n > 0) {
        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 <vector>
#include <algorithm>

using namespace std;

int main() {
    int n,s;
    while (1) {
        cin >> n;
        if(n==0) break;
        int p = n;
        vector<int> score;
        cin >> s;
        n--;
        score.push_back(s);
        int mins=s,maxs=s,result=0;
        while(n--){
            cin >> s;
            maxs = max(maxs,s);
            mins = min(mins,s);
            score.push_back(s);
        }
        vector<int>::iterator it;
        it = score.begin();
        bool maxf=false,minf=false;
        while(it != score.end()){
            if (((*it)==mins) && (minf == false)) {
                minf = true;
            }
            else if(((*it)==maxs) && (maxf == false)){
                maxf = true;
            }
            else{
                result += (*it);
            }
            it++;
        }
        cout << result/(p-2) << endl;
    }
}

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

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

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

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int a,b[100];
  while(1)
  {
    scanf("%s",&a );
    if(a == 0)
    {
      break;
    }

    for(int i=0; i<a; i++)
    {
      scanf("%d",&b[i] );
    }

    sort(b,b+a);

    int c = 0;
    for(int i=1; i < a-1; i++)
    {
      c+=b[i];
    }
    printf("%d\n",c / (a-2) );
  }
}

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

using namespace std;

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

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define UNIQUE(o) (o).erase(unique(sort(all((o)))))

typedef long long ll;
const int N = 100;
const int S = 1000;
int n;
int c[S+1];

int main() {
  int s;
  scanf("%d ", &n);
  while (n) {
    memset(c, 0, sizeof(c));
    int res = 0;
    int max_idx = 0, min_idx = S;
    REP(i,n) {
      scanf("%d ", &s);
      c[s]++;
      max_idx = max(max_idx, s);
      min_idx = min(min_idx, s);
      res += s;
    }
    res -= max_idx;
    res -= min_idx;
    n -= 2;
    res /= n;
    printf("%d\n", res);
    scanf("%d ", &n);
  }

  return 0;
}

C++: #include <iostream>

using namespace std;
int main(){
	int zero;
	while(1){
		
		int N;
		int* score;
		int S = 0;
		int max = 0;
		int min = 0;
	
		cin >> N;
		
		if(N == 0){
			return 0;
		}
		
		score = new int[N];
		for(int i=0; i<N; ++i){
			cin >> score[i];
			S += score[i];
			
			if( i == 0 ){
				max = min = score[i];
			}
		
			if( max < score[i] ){
				max = score[i];
			}
			if( min > score[i] ){
				min = score[i];
			}
		}
		S -= max;
		S -= min;
	
		cout << (int)S/(N-2) << endl;

		delete[] score;
	}

}

C++: #include<bits/stdc++.h>
using namespace std;
#define OUT(x) cout<<x<<endl
#define debug(x) cout<<#x<<": "<<x
const int BA = 1000;
const int INFTY = (1<<21);
int main(){
  int n,ans;
  int s[1001];
  while(cin>>n&&n){
    ans = 0;
    for(int i=0;i<n;i++)cin >> s[i];
    
    sort(s,s+n);
    for(int i=1;i<n-1;i++)ans+=s[i];
    ans/=n-2;
    OUT(ans);
  }
}

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

using namespace std;

int main()
{
    int n;
    while(cin >> n, n)
    {
        int max_s, min_s, sum;
        cin >> max_s >> min_s;
        sum = max_s + min_s;
        if(max_s<min_s) swap(max_s, min_s);
        for(int i=2; i<n; i++)
        {
            int s;
            cin >> s;
            sum += s;
            if(max_s<s) max_s = s;
            if(min_s>s) min_s = s;
        }
        cout << (sum - max_s - min_s) / (n - 2) << endl;
    }
}

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

int main()
{
	int in,a,maxer=0,miner=1000;
	int sum=0;
	int i=0;
	double ave=0.0;
	while( cin >> in,in ){
		for(i=0; i<in; i++){
			cin >> a;
			maxer=max(a,maxer);
			miner=min(a,miner);
			sum += a;
		}
		sum = sum - maxer - miner;
		ave = sum/(in-2);
		cout << floor(ave) << endl;
		sum = maxer = ave = 0;
		miner=1000;
	}
}

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

int main() {
    for(;;){
        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);
        int ans=0;
        for (int i=1;i<n-1;i++) {
            ans+=a[i];
            }
        cout<<ans/(n-2)<<"\n";
        }
}

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; }
        vector<int> vc(n);
        
        for(int i=0; i<n; i++){
            cin >> vc[i];
        }
        auto mm = minmax_element(vc.begin(),vc.end());
        auto res = (accumulate(vc.begin(), vc.end(), 0)) - (*mm.first + *mm.second);
        cout << res / (n-2) << endl;
    }
    return 0;
}