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

C++: 
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>

#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main() {
	
	int N;

	while(cin >> N && N)
	{
		vector<int> score(N,0);
		rep(i, N){
			cin >> score[i];
		}

		int max_s = *max_element(ALL(score));
		int min_s = *min_element(ALL(score));

		//dump(max_s); dump(min_s);

		rep(i,N){if(score[i]==max_s){score.erase(score.begin()+i);break;}}
		rep(i,N){if(score[i]==min_s){score.erase(score.begin()+i);break;}}
	
		//DUMP(score);

		int ave = accumulate(ALL(score),0) / score.size();
		
		cout << ave << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <cstdint>

using namespace std;

int main()
{
  while(true){
    unsigned int n;
    cin >> n;

    if(n == 0) break;

    unsigned int min_val = UINT32_MAX;
    unsigned int max_val = 0;
    unsigned int count = 0;
    for(unsigned int i = 0; i < n; i++){
      unsigned int val;
      cin >> val;
      min_val = min(val, min_val);
      max_val = max(val, max_val);
      count += val;
    }
    cout << (count - min_val - max_val) / (n -2) << endl;
  }
  
  return 0;
}

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

int main(void)
{
	int num,n,max,min,sum,ave,i;
	
	while(cin >> num){
		if(num == 0){
			break;
		}

		sum = 0;
		ave = 0;
		for(i = 0; i < num; i++){
			cin >> n;
			if(i == 0){
				max = n;
				min = n;
			}else{
				if(max < n){
					max = n;
				}
				if(min > n){
					min = n;
				}
			}
			sum += n;
		}
		sum = sum - max - min;
		ave = sum / (num - 2);
		cout << ave<< endl;
	}

	return 0;
}

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

int main()
{
  int n;
  int kazu=0,sum=0;
  int max,min;

  while(1)
    {
      cin >> n;

      if(n == 0)break;

      sum = 0;

      for(int i = 0;i < n;i++)
	{
	  cin >> kazu;
	  sum += kazu;

	  if(i == 0)
	    {
	      max = kazu;
	      min = kazu;
	    }

	  if(max < kazu) max = kazu;

	  if(kazu < min) min = kazu;
	}
      sum = sum - max - min;

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

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


int main(){
  int n;
  int score;
  while(cin >> n && n){
    int lc = 1000;
    int uc = 0;
    score = 0;
    for(int i = 0; i < n; i++){
      int num;
      cin >> num;
      score += num;
      lc = min(lc, num);
      uc = max(uc, num);
    }
    cout << (score - uc - lc) / (n - 2) << endl;
  }
  return 0;
}