#include<stdio.h> #include <malloc.h> void sort(int a[],int len){ int count = 0; //printf("len:%d\n",len); int tmp = (int) (len * 0.8); while(tmp >= 1){ for(int i=0;i<len;i++){ count++; if(i + tmp < len && a[i] > a[i+tmp]){ a[i] = a[i] + a[i+tmp]; a[i+tmp] = a[i] - a[i+tmp]; a[i] = a[i] - a[i+tmp]; }else if(i+tmp >= len){ break; } } tmp *=0.8; } } int main(){ int n; while(scanf("%d",&n)!= EOF){ int *p = malloc(sizeof(int)*n); for(int i=0;i<n;i++){ scanf("%d",p+i); } double result = 0; sort(p,n); for(int i=1;i<n-1;i++){ result +=*(p+i); } printf("%0.2lf\n",result/(n-2)); } return 0; }
HDU 2014
最新推荐文章于 2020-09-06 21:20:38 发布