标签:
5 8.3 9.2 8.7 8.9 9.0 0
4
1 #include<cstdio> 2 #include<cmath> 3 #include<cstring> 4 #include<iostream> 5 #include<algorithm> 6 #include<cstdlib> 7 using namespace std; 8 double a[15]; 9 double b[15]; 10 int main() 11 { 12 int n,i; 13 while(scanf("%d",&n)!=EOF&&n) 14 { 15 int ma=0,mi=0; 16 double sum=0.0; 17 for(i=1;i<=n;i++) 18 { 19 scanf("%lf",&a[i]); 20 if(a[i]>a[ma]||ma==0)ma=i; 21 if(a[i]<a[mi]||mi==0)mi=i; 22 sum+=a[i]; 23 } 24 sum-=a[mi];sum-=a[ma]; 25 double ave=sum/(n-2); 26 a[mi]=30.0;a[ma]=30.0; 27 mi=0; 28 for(i=1;i<=n;i++) 29 { 30 b[i]=abs(a[i]-ave); 31 if((mi==0)||(b[i]<b[mi]))mi=i; 32 } 33 printf("%d\n",mi); 34 } 35 return 0; 36 }
标签:
原文地址:http://www.cnblogs.com/Annetree/p/5863044.html