poj3325

水题,求平均数

#include <stdio.h>

int main()
{
	//freopen("D:\\t.txt", "r", stdin);
	int n;
	while (scanf("%d", &n) != EOF && n != 0)
	{
		int i;
		int xmin, xmax, sum;
		scanf("%d", &xmin);
		xmax = xmin;
		sum = xmin;
		for (i = 1; i < n; i++)
		{
			int a;
			scanf("%d", &a);
			sum += a;
			if (xmin > a)
				xmin = a;
			if (xmax < a)
				xmax = a;
		}
		printf("%d\n", (sum - xmin - xmax) / (n - 2));
	}
	return 0;
}

posted @ 2011-02-01 12:38  金海峰  阅读(267)  评论(0编辑  收藏  举报