Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

30题,用下快排,掐头去尾。。答案就出来了。。。好水啊

Posted by 411018149 at 2012-07-18 15:24:19 on Problem 3325
#include <stdio.h>
#include <stdlib.h>
int cmp (const void *a, const void *b)
{
	return (*(int *)a-*(int *)b);
}
int main()
{
	int num;
	int i;
	int a[100];
	while (scanf("%d", &num)!=EOF)
	{
		if (num==0) break;
		for(i=0; i<num; i++)
			scanf("%d", &a[i]);

		qsort (a,num,sizeof(a[0]),cmp);
	
		int total=0;
		for (i=1;i<num-1;i++)
			total=total+a[i];
		printf ("%d\n", total/(num-2));
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator