Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
30题,用下快排,掐头去尾。。答案就出来了。。。好水啊#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator